How can I combine more cc files in one project?
How can I combine more cc files in one project?
? #include ?
-"What we wish, we readily believe, and what we ourselves think, we imagine others think also."PHP Code:
sadf
>? #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
My best code is written with the delete key.
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.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
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.
-"What we wish, we readily believe, and what we ourselves think, we imagine others think also."PHP Code:
sadf
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 }
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law