S
Simon
Hi,
I think this is slightly OT, (I am not certain that Macros are part of the
standard), but I am hopping that someone could help.
I am trying to use a language file in my system.
the format of the file would be something like
[option]
open=Open
close=Close
....
and so on.
Now I want to create some macros that I could use all over the place in all
the functions that would output text to the screen.
something like
SetMenuText( LANG_CLOSE ); or DisplayMessage( LANG_HELLOWORLD ); and so one
....
where the macro would represent...
#define LANG_CLOSE GetLanguagefile( "option", "close",
"Close" );
#define LANG_HELLOWORLD GetLanguagefile( "option", "hellow", "Hello
world..." );
but my problem is the return value, I would like to return a const char* or
even a char* but I don't think it is possible to return them directly.
I could have a global char *, char * g_szReturn = NULL; but is it really
safe to use it that way?
I need to return the function otherwise the macro are not very useful really
because I would have to add 2 or three lines of code every time.
Like
char szText[1024];
if( GetLanguagefile( "option", "close", "Close", szText, 1024 ) ){
SetMenuText( szText );
}
Any ideas how I could safely return a const char* or char *?
Many thanks.
Simon
I think this is slightly OT, (I am not certain that Macros are part of the
standard), but I am hopping that someone could help.
I am trying to use a language file in my system.
the format of the file would be something like
[option]
open=Open
close=Close
....
and so on.
Now I want to create some macros that I could use all over the place in all
the functions that would output text to the screen.
something like
SetMenuText( LANG_CLOSE ); or DisplayMessage( LANG_HELLOWORLD ); and so one
....
where the macro would represent...
#define LANG_CLOSE GetLanguagefile( "option", "close",
"Close" );
#define LANG_HELLOWORLD GetLanguagefile( "option", "hellow", "Hello
world..." );
but my problem is the return value, I would like to return a const char* or
even a char* but I don't think it is possible to return them directly.
I could have a global char *, char * g_szReturn = NULL; but is it really
safe to use it that way?
I need to return the function otherwise the macro are not very useful really
because I would have to add 2 or three lines of code every time.
Like
char szText[1024];
if( GetLanguagefile( "option", "close", "Close", szText, 1024 ) ){
SetMenuText( szText );
}
Any ideas how I could safely return a const char* or char *?
Many thanks.
Simon