How can I combine more cc files in one project?
Printable View
How can I combine more cc files in one project?
? #include ?
>? #include ?
No, including source files is a Bad Thing(tm). You include headers, and link with source files.
>How can I combine more cc files in one project?
You link them together when you invoke the compiler and allow it to link as well, or link the resulting object files if you use a compile-only switch.
Code:$ g++ src1.cc src2.cc src3.cc
or
$ g++ -c src1.cc src2.cc src3.cc
$ g++ src1.o src2.o src3.o
Depends on your environment. With Visual Studio and other IDEs, you can create/import additional source files. With projects based on make or make-like tools (ant, jam, ...) you need to edit the makefile/jamfile/whatever and add those sources to make sure they're compiled and linked along with the first one.
What if I used in different source files same names of variables, functions etc. that have different functions in in different files?
Is there any fast and effient way of solving this problem except of going over each name and changing it?
Thank you
if there was a way, it would lead to very very messy code. Copy/Paste would be your best choice IMO.
In C++, anonymous namespaces, which make symbols invisible outside the files. Basically, just put everything you only need in the file it is in in
Code:namespace {
// code here
}