Justin Payne Posted July 6, 2014 Share Posted July 6, 2014 I'm having a difficult time getting my head around how to use C preprocessor directives in Pure C. In the English documentation, it appears as those the only #pragma option is "warn". I would like to be able to print some info out to the command window, such as __DATE__ and __TIME__ but something like #pragma message __DATE__ doesn't work nor does... #ifdef __PUREC__ printf("Pure C version is %s", __PUREC__); #endif Eventually, I'd like to see if I can include different header depending on the compiler (PureC vs GCC). For example, in Pure C, v_opnvrk() exists in vdi.h but in GCC, it lives in mt_gem.h. I was thinking of handling that so that when I try to compile in both, I don't have to change the code. Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted July 6, 2014 Share Posted July 6, 2014 Are you sure __PUREC__ is a string? As a quick test just try :- #if defined(__PUREC__) ffffff; #endif Looks like gibberish and thats because it is . If the compiler complains at the fffff; line you know that __PUREC__ is #defined. Quote Link to comment Share on other sites More sharing options...
Justin Payne Posted July 7, 2014 Author Share Posted July 7, 2014 (edited) Nope, I don't know for sure. The English document doesn't specify. They also had __TURBOC__ which is supposed to mean the same thing, which is the version of the compiler. I guess it could be an Int or a float or... So, if it's defined, then what? Edited July 7, 2014 by Justin Payne Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted July 8, 2014 Share Posted July 8, 2014 Nope, I don't know for sure. The English document doesn't specify. They also had __TURBOC__ which is supposed to mean the same thing, which is the version of the compiler. I guess it could be an Int or a float or... So, if it's defined, then what? Its been a loooooong time since I looked at any "C" on the ST. However, in the PureC package I found online, I could see __PUREC__ used in some of the shipped header files so it should be available in your "C" code. Try doing a printf with a sting and __DATE__ and then look in the executable with a hex editor for the human readable date that your emulator/ST is currently set to. Since its a German utility the date will most likely be in day.month.year format. Quote Link to comment Share on other sites More sharing options...
Justin Payne Posted July 8, 2014 Author Share Posted July 8, 2014 Shouldn't I see that date printed put to the output window? Quote Link to comment Share on other sites More sharing options...
phoenixdownita Posted July 9, 2014 Share Posted July 9, 2014 (edited) The issue for now is that you don't know if it is a string. printf("Pure C version is %s", __PUREC__); may just cause a seg fault, but what you could try is printf("Pure C version is %d", __PUREC__ + 1); if __PUREC__ is not an integer then it will fail to compile, so now you know it may be a string, I say may because sometimes you can just define symbols for the sake of the preproc finiding them in #ifdef but they actually do not carry any info per se, not sure if back in the days it was possible, but if it was according to here http://www.cprogramming.com/reference/preprocessor/define.html it should be the "" empty string. Edited July 9, 2014 by phoenixdownita Quote Link to comment Share on other sites More sharing options...
joyfulcoder Posted July 9, 2014 Share Posted July 9, 2014 According to the English docs there is no support for "#pragma message" but the following will work for including headers based on the compiler. #ifdef __PUREC__ #include <vdi.h> #else /* assume GCC */ #include <mt_gem.h> #endif Quote Link to comment Share on other sites More sharing options...
Justin Payne Posted July 17, 2014 Author Share Posted July 17, 2014 (edited) According to the English docs there is no support for "#pragma message" but the following will work for including headers based on the compiler. #ifdef __PUREC__ #include <vdi.h> #else /* assume GCC */ #include <mt_gem.h> #endif Yes, I think that might work. The printf()'s where throwing errors. Thank! Edited July 17, 2014 by Justin Payne Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.