Omnimaga

Calculator Community => Casio Calculators => Topic started by: ruler501 on June 11, 2012, 02:14:46 pm

Title: Prizm Preprocessor symbols
Post by: ruler501 on June 11, 2012, 02:14:46 pm
I was planning on writing a C game that could run on both prizm and nspire and I wanted it to detect which it was being compiled for at build time are there any preprocessor symbols I could use for that?

Title: Re: Prizm Preprocessor symbols
Post by: blue_bear_94 on June 11, 2012, 02:38:02 pm
You can write header files for each device containing definitions of constants and functions. Then use functions from the necessary header file.
Title: Re: Prizm Preprocessor symbols
Post by: ruler501 on June 11, 2012, 02:41:18 pm
but how could I have it switch at compile time between the two?
Title: Re: Prizm Preprocessor symbols
Post by: Juju on June 11, 2012, 02:41:23 pm
IMO preprocessor symbols would be preferable. I wondered that too yesterday.
Title: Re: Prizm Preprocessor symbols
Post by: blue_bear_94 on June 11, 2012, 02:41:50 pm
You just change the #include statement.
Title: Re: Prizm Preprocessor symbols
Post by: ruler501 on June 11, 2012, 02:42:24 pm
I would rather it not have to have any changes to source to compile for each platform
Title: Re: Prizm Preprocessor symbols
Post by: Juju on June 11, 2012, 02:43:32 pm
Preprocessor symbols would also help for switching the #include. If you had to release the code, the user won't have to change some code, they would just change the compiler and type make.
Title: Re: Prizm Preprocessor symbols
Post by: ruler501 on June 11, 2012, 02:46:10 pm
that was the basic idea of what i wanted to do.
though i think i might be able to do it the makefile since i'd probably have to make seperate targets for nspire and prizm since they get to tns/g3a in different ways
Title: Re: Prizm Preprocessor symbols
Post by: alberthrocks on June 11, 2012, 03:23:19 pm
I think you would need to contact the Ndless maintainers and the PrizmSDK maintainers.
(Namely, ExtendeD for Ndless and Jonimus for PrizmSDK.)

I think something like __NSPIRE__ and __NDLESS__ for building on Nspire, and __PRIZM__ for building on Prizm would work.
Title: Re: Prizm Preprocessor symbols
Post by: ruler501 on June 11, 2012, 03:24:42 pm
Looking at the nSDL code its _NSPIRE for nspire
and I was thinking that if there isn't one that __PRIZM__ or _PRIZM would work if it wasn't too hard to add in

EDIT: Correction the nSDL code says _TINSPIRE not _NSPIRE
Title: Re: Prizm Preprocessor symbols
Post by: alberthrocks on June 11, 2012, 03:33:47 pm
Looking at the nSDL code its _NSPIRE for nspire
and I was thinking that if there isn't one that __PRIZM__ or _PRIZM would work if it wasn't too hard to add in
The _NSPIRE you see doesn't actually exist yet in the Ndless includes (or maybe my searching foo is terrible :P). Instead, it may be a runtime define (-D_NSPIRE) instead of an in-SDK one.

These are relatively easy to add in compared with the other tasks of making a good SDK, but you just need to let them know! ;)
Title: Re: Prizm Preprocessor symbols
Post by: ruler501 on June 11, 2012, 03:35:43 pm
I dont see the runtime define in the makefile so i don't think its there

EDIT: fixed my previous post with the correct symbol :P

EDIT2: and searching with grep i can't find any define for it in the nSDL source
Title: Re: Prizm Preprocessor symbols
Post by: alberthrocks on June 11, 2012, 03:42:43 pm
I dont see the runtime define in the makefile so i don't think its there

EDIT: fixed my previous post with the correct symbol :P
Sorry, I can't seem to find that define.

(I searched his Github: https://github.com/search?q=_TINSPIRE&repo=&langOverride=&start_value=1&type=Code&language=)
Title: Re: Prizm Preprocessor symbols
Post by: ruler501 on June 11, 2012, 03:47:48 pm
here it is https://github.com/Hoffa/nSDL/blob/master/include/SDL_platform.h#L105
in the nSDL github
Title: Re: Prizm Preprocessor symbols
Post by: alberthrocks on June 11, 2012, 04:09:11 pm
here it is https://github.com/Hoffa/nSDL/blob/master/include/SDL_platform.h#L105
in the nSDL github
Aha, I found it:
In tools/build/nspire-gcc (of the ndless source), there's one line - the final line - that has that runtime define:
"$GCC" -mcpu=arm7tdmi -I "$DIRNAME/../include"  -I "$USERPROFILE/.ndless/include" -fpic -fno-builtin -D _TINSPIRE "$@"

Kinda sneaky, eh? :) I still would prefer to have that define in the header itself (which you can prod the devs to do), but yup, that define works for now.
Title: Re: Prizm Preprocessor symbols
Post by: ruler501 on June 11, 2012, 04:12:45 pm
for now I think runtime defines will work but I will probably prod the devs to add it in eventually