Jump to content
IGNORED

Pure C pre-processor


Recommended Posts

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.

Link to comment
Share on other sites

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 by Justin Payne
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by phoenixdownita
Link to comment
Share on other sites

  • 2 weeks later...

 

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 by Justin Payne
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...