Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • Aren't c files compiled by GCC C Compiler and cpp files by GCC C++ Compiler ? Commented Nov 21, 2013 at 9:06
  • @mini-me But if you're coding C++, then you won't have any C files in your own project, will you? The nice thing about libraries made in C (or which exports a C interface) is that they can be used from almost anything else, especially C++. Commented Nov 21, 2013 at 9:09
  • I still have some c files in my project that have some utility functions. Are you suggesting to rename them to *.cpp ? Commented Nov 21, 2013 at 9:13
  • @mini-me Okay, but you compile them to object files linked with the rest of the project, or do you link the C code into a separate dynamic library or program? Or by the phrase "include all libraries twice" do you mean the #include directive? If so, then yes you need to #include the header files if you use them in a source file (no matter if it's a C or C++ source file). How else would the source file know about the declarations in the header file? Commented Nov 21, 2013 at 9:15
  • No, it's 1 big project. And and including twice means in the project settings. Commented Nov 21, 2013 at 9:18