Thread: Problem with compiling a multiple source files involve header file

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    5

    Problem with compiling a multiple source files involve header file

    Hi guys, when i using g++ ver 4.3 to compile plenty source files, process is OK, no error or warning occurs but it made a file name like <header_filename>.h.gch, for example i have hello.hh header file, it will be made hello.hh.gch. I try to open this file but it's a binary file. So what i need to solve this problem, i wonder myself this is a error? or what is this?.

    Thank you for any help provided.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    It looks like you are using pre-compiled headers. Was that your intention?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    5
    yes, that's right, i used something like that in my header file:
    #ifndef header_h
    #define header_h

    // declare area

    #endif
    but when i using these instruction will be made file *.gch ?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by meterpreter
    but when i using these instruction will be made file *.gch ?
    No, that is just a typical header inclusion guard.

    I suggest that you read the GCC documentation on pre-compiled headers. Since you did not create any files with the ".gch" extension yourself, my guess is that you used the -include compiler option unintentionally.

    If so, then a solution if you do not want to use pre-compiled headers is to delete all those ".gch" files and then avoid passing -include to gcc or g++.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Sep 2011
    Posts
    5
    That's perfect, problem is solved but..

    I have another question not relative with this topic. I've just sign in (yes, of course), then i click on setting on the top-right of this page, then i chose general setting, i changed theme forum form default to mobile theme (i don't remember exactly), so the question is "what is need to undo my act"?. sorry for this stupid.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You probably need to find the general settings for the forum in the mobile theme somehow then change forum skin to normal style.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User PuKa's Avatar
    Join Date
    Oct 2011
    Posts
    23
    Access is denied when i try to click on "Profile". That's annoying, another way i registry a new account names puka . Th@nks for reply.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling multiple source codes
    By JonathanS in forum C Programming
    Replies: 6
    Last Post: 09-21-2011, 01:41 AM
  2. facing problem with multiple source file porgram.
    By learning"c" in forum C Programming
    Replies: 10
    Last Post: 05-15-2011, 12:08 PM
  3. compiling multiple source files
    By jtieu in forum C++ Programming
    Replies: 4
    Last Post: 03-29-2011, 06:51 PM
  4. compiling source files and header file at once?
    By 1jackjack in forum C Programming
    Replies: 10
    Last Post: 05-04-2007, 11:06 AM
  5. Replies: 1
    Last Post: 05-01-2003, 02:52 PM