Thread: #include makes problems

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    244

    #include makes problems

    hi!

    #include just replaces the text within the include file with the line "#include..."
    but it seems like that when i use a command within that include file which takes use of a library, it sais "command not found" or somethin...

    when i manually replace the line with the #include command with that function, everything works well.

    any reasonable explanation?
    thanks

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    #include "filename.h" essentially replaces that line with the contents of filename.h - slightly different that what you wrote. Of course, filename.h needs to exist, and the compiler must be able to find it.

    Forgive me if English is not your first language, but I really can't determine what exactly your problem is. Reword your original request, or perhaps provide code, along with how you compile/link that code, that demonstrates your problem.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    244
    i am including cpp files instead of h (header) files... could that be the reason for this?

    anyway: when i replace the include line with the code thats in that include file, it works well. and thats what bothers me

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    i am including cpp files instead of h (header) files... could that be the reason for this?
    Maybe. I do not think compilers actually care about the file extension of header files, but it might interfere with how an IDE builds your program and such. Generally, just choose between .h and .hpp for header files, and stick with it across your project.
    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
    Jan 2008
    Posts
    244
    yes. it now seems to me like it works perfect when i use the *.h header file extension.
    everything fine now!
    thanks dudes

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with include?
    By c9dw2rm8 in forum C Programming
    Replies: 3
    Last Post: 02-21-2008, 01:29 PM
  2. some problems with #include
    By Cmaniac in forum C Programming
    Replies: 6
    Last Post: 04-15-2007, 11:28 PM
  3. more include file problems
    By whackaxe in forum C++ Programming
    Replies: 1
    Last Post: 04-19-2004, 07:09 AM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM