Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2007
    Location
    Sofia, Bulgaria
    Posts
    9

    #include statements messed up

    Hi, i have a rather stupid problem that i can't fix. It's about the C++ game design VTM (Evil Monkeys). I somehow managed to mess up the #include statements and can't find the right frames in the VTM. I also don't understand how exactly does the class prototyping work and what is the whole point of the
    #ifndef
    #define

    #endif
    statements since even when they are present, if i include a header where i'm not supposed to, these directives don't stop the circular thing from going on.
    That's how i've always thought it works but it seems i've got it wrong.
    I need some help it seems...

  2. #2
    Join Date
    Apr 2007
    Location
    Sofia, Bulgaria
    Posts
    9
    If anyone pastes the #include statements for each file (which wouldn't be too hard) almost everything will be ok

  3. #3
    Join Date
    Aug 2003
    Location
    Leeds, UK
    Posts
    175
    I see this as a good opportunity for you to practice your debugging skills
    QuokOS - A modern, general purpose, UNIX-like hobby OS.

  4. #4
    Join Date
    Apr 2007
    Location
    Sofia, Bulgaria
    Posts
    9
    i've been practicing for two days straight now and this is the reason i'm asking for help. Even if noone helps i will continue practicing because i have no other choice

  5. #5
    Join Date
    Jun 2003
    Location
    Fornebu, Norway
    Posts
    149
    Going over the VTM's one more time certainly does not hurt you.

    regarding #ifndef #define _X_H #endif, it's first of all a code standard.
    To be honest i have not bothered to break the standard for the last 8-9 years i have worked with C\C++, so i cant point to, too many practical issues other than noted in the VTM, however whether you get into a infinite loop or not comes down to the compiler, also defined constant aren't to happy to have multiple references, as the linker does not know which one to choose from.

    A later standard is used as "#pragma once" on top of your header if you feel more comfortable with that, so nothing at the end of the file. While other coders might want you to use #ifdef rathern than #Pragma calls.

    The key is, if you plan to work with others, or\and understand code from others more efficiently, you are better off, following the standard to one degree or another.
    - RiviEr

  6. #6
    Join Date
    Apr 2007
    Location
    Sofia, Bulgaria
    Posts
    9
    I added
    #ifndef LEVEL_H
    #include "level.h"
    #endif

    to Sprite.h and now it works, problem finally solved.

  7. #7
    Join Date
    Apr 2007
    Location
    Sofia, Bulgaria
    Posts
    9
    Aren't #pragma statements a microsoft thing ?

  8. #8
    Join Date
    Feb 2005
    Location
    Bellevue, WA
    Posts
    3,251
    #pragma is not standard and I believe gcc dropped support for it.

    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." ~Rich Cook

  9. #9
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    Quote Originally Posted by owensd View Post
    #pragma is not standard and I believe gcc dropped support for it.
    to be precise: the #pragma directive itself is indeed part of the standard, however, its parameters are not. that means, if you feed #pragmas to a standard-compliant compiler, the worst thing that can happen is that they are simply ignored. an unknown pragma will never raise a compiler error though.

  10. #10
    Join Date
    Feb 2005
    Location
    Bellevue, WA
    Posts
    3,251
    Quote Originally Posted by ComicSansMS View Post
    to be precise: the #pragma directive itself is indeed part of the standard, however, its parameters are not.
    Touché.

    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." ~Rich Cook

Posting Permissions

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