FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SDL_GetError() problem

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
zane.sims



Joined: 07 Aug 2007
Posts: 40

PostPosted: Tue Dec 11, 2007 9:01 am    Post subject: SDL_GetError() problem Reply with quote

Hello,

I am having some trouble understanding how to concatinate SDL_GetError()'s return with my own string.

if I do something like this:
Code:
log("Unable to init SDL: " ~ SDL_GetError());

//where log() is:
void log(char[] msg)
{
   File f = new File("log.txt", FileMode.Out);
   
   f.writeLine(msg);
   
   f.close();
}


When building I get:
main.d(53): Error: Can only concatenate arrays, not (char* ~ char*)
main.d(53): function main.log (char[]) does not match parameter types (int)
main.d(53): Error: cannot implicitly convert expression ("Unable to init SDL: "
~ (*SDL_GetError)()) of type int to char[]


If someone knows what I am doing wrong, please explain it to me as I am interested in understanding how concatenation and strings work in D. I have read about it, but perhaps someone else can give further insight.

Thanks,
Zane
_________________
わたしがプログラマだよ!
Back to top
View user's profile Send private message
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Tue Dec 11, 2007 3:40 pm    Post subject: Reply with quote

You can only concatenate D strings, you are trying to concatenate C strings. Call the toString function in std.string for phobos or toString (former toUtf8, don't remember in what module) for tango to convert to a D string.
Back to top
View user's profile Send private message
zane.sims



Joined: 07 Aug 2007
Posts: 40

PostPosted: Tue Dec 11, 2007 4:34 pm    Post subject: Reply with quote

Thanks very much!

Argh, I can't believe I made such a stupid mistake Smile.

Thanks again,
Zane
_________________
わたしがプログラマだよ!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group