Code Header Files

This is a discussion on Code Header Files within the C++ Programming forums, part of the General Programming Boards category; How can I combine more cc files in one project?...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    50

    Code Header Files

    How can I combine more cc files in one project?

  2. #2
    Bioport Productions
    Join Date
    Oct 2005
    Posts
    215
    ? #include ?
    -"What we wish, we readily believe, and what we ourselves think, we imagine others think also."
    PHP Code:
    sadf 

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >? #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.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    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

  5. #5
    Registered User
    Join Date
    Dec 2004
    Posts
    50

    Cc

    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

  6. #6
    Bioport Productions
    Join Date
    Oct 2005
    Posts
    215
    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 

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help using Header Files
    By d34n in forum C Programming
    Replies: 8
    Last Post: 04-22-2008, 12:06 AM
  2. include library header in header files
    By Raison in forum C++ Programming
    Replies: 6
    Last Post: 09-27-2004, 03:50 AM
  3. Missing header files and libraries with Borland
    By quagsire in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2003, 06:19 AM
  4. What /what not to put in header files
    By Just in forum C Programming
    Replies: 1
    Last Post: 12-14-2002, 10:45 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21