Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Prozak

How to fail Compilation: Pragma?

This topic is 6182 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I would like to fail compilation, if certain events occur, using #ifdef, and others. How do i go about accomplishing this?

[Hugo Ferreira][Positronic Dreams][]
"Research is what I''m doing when I don''t know what I''m doing."
- Wernher Von Braun (1912-1977)

Share this post


Link to post
Share on other sites
Advertisement
You''ll need to be a bit more specific. There''s a ton of things that can be done using the preprocessor (look up the __FILE__ and __LINE__ identifiers, which can return compile-tiime error information for example). Also take a look at the MSVC-specific #pragma message, #pragma warning( error : xxxx ), #warning and #error preprocessor/conditional directives.

Happy Hacking!

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
I''m using VC++6, and will only be using it,
lets say:
#define USING_DX_INPUT

now, later:
#ifndef USING_DX_INPUT
do something that will fail compile here!
#endif

see? I just want to fail compile, using some directives...

[Hugo Ferreira][Positronic Dreams][]
"Research is what I''m doing when I don''t know what I''m doing."
- Wernher Von Braun (1912-1977)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think you just stated your own solution:

#ifndef USING_DX_INPUT
do something that will fail compile here!
#endif

type exactly this into your source.

Or better:

#ifndef USING_DX_INPUT
You must define Direct Input !
#endif

Share this post


Link to post
Share on other sites
oops, theres one thing that isn''t working the way it should.
In one file I have "#def alpha",
and in another I have "#ifndef alpha (do stuff...)""

Basicly, there''s one file in my project that requires the
presence of another file.
Lets call them A and B, B needs A to function properly.
So, in A I have:
#def A_PRESENT

And in B i have:
#ifndef A_PRESENT
#error You need file A.h to compile this correctly
#endif

The problem is, I think, the compiler goes over B first,
and because A_PRESENT isn''t yet defined, it automaticly fails,
although A is present...

Anyone can help me change the order of compilation, or force
all the defines to be defined before compilation starts?

How do I work arround this one?
Thsnx for any help,







[Hugo Ferreira][Positronic Dreams][]
"Research is what I''m doing when I don''t know what I''m doing."
- Wernher Von Braun (1912-1977)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
in VC++ (6.0), go to your Project-Settings, C/C++, Preprocessor definitons and enter your Macros there

Share this post


Link to post
Share on other sites
quote:
Original post by pentium3id
And in B i have:
#ifndef A_PRESENT
#error You need file A.h to compile this correctly
#endif

Try this instead:
// B.h
#include "A.h"

#ifndef A_PRESENT
#error You need file A.h to compile this correctly
#endif

Since you explicitly include A in B this time, A should be processed first. Alternatively, you could include both files in another header C, A first. That should also yield the same result (so long as all other files include A and/or B through C).

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!