Omnimaga
Calculator Community => Casio Calculators => Topic started 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?
-
You can write header files for each device containing definitions of constants and functions. Then use functions from the necessary header file.
-
but how could I have it switch at compile time between the two?
-
IMO preprocessor symbols would be preferable. I wondered that too yesterday.
-
You just change the #include statement.
-
I would rather it not have to have any changes to source to compile for each platform
-
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.
-
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
-
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.
-
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
-
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! ;)
-
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
-
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=)
-
here it is https://github.com/Hoffa/nSDL/blob/master/include/SDL_platform.h#L105
in the nSDL github
-
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.
-
for now I think runtime defines will work but I will probably prod the devs to add it in eventually