Results 1 to 4 of 4

Thread: Managing multiple C++ files in one project

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    12

    Managing multiple C++ files in one project

    Hello, I am working on a project that I feel will be rather big, so instead of having all my code in one huge cpp file I wish to split the cpp files so that one cpp file handles one set of functions, and another cpp file handles another set of functions.

    I really am clueless how to do this. When I tried at first to add cpp files, then I get the error message that some of my global variables have not been declared.

    What is the best and most organized way of solving my problem? Any help will be appreciated.

    Thanks.

  2. #2
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    'extern' all your variables in all other cpp files, except the one they are declared in.

    eg,

    extern int cnt;
    extern char mychar;

    This is to tell the compiler that those variables have been declared elsewhere but not in this cpp file(external to this file)

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Or better yet, extern them in a common header file.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    12

    Thank you

    I would just like to sincerely thank you guys for answering my question in a simple manner.

    I got it to work exactly how I wanted it to and now I can easily go back and forth between different sections of code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width