Jump to content
  • Advertisement


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


Global Strings

This topic is 6544 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

This is a silly question for someone coding this long but... How do I create a global string ? The following emaple doesn''t work but I''d imagine it something along these lines const byte *TOKEN_QUIT = "quit"; Normaly I''d create the ram then fill it but essentially I just want a replacement for #define that has a type...

Share this post

Link to post
Share on other sites
I don't see anything wrong with what you have there, but it's not exactly how I'd do it. At the global scope (not in any function) I'd do:

const char szTokenQuit[] = "quit";

Then you can just use "szTokenQuit" anyplace in your code to get to the string.
The real advantage to this is that there is only one instance of the string "quit" in memory. If you use a #define, then you could have instances of your string for each usage of the macro (compiler optimizations asside).
The disadvantage is that if you are using multiple source files then you have to declare the variable in one file and then "extern" it from every other file that want's to use it.

Edited by - syzygy on July 23, 2000 9:25:53 PM

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!