Passing a char string

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Passing a char string

Post by Ghoti »

hi folks,

I'm trying to pass a char string to a function i do it like i always do but suddenly it gives warnings it may be the function to which i pass the string but i do not know for certain.

my code:

Code: Select all

	int SoundLoad(int i, const char *sMsg){

		switch(i) {

		case 1:	{
				Sound1 = Sample_Load(sMsg);
				break;
				}
		case 2:	{
				Sound2 = Sample_Load(sMsg);
				break;
				}
		case 3:	{
				Sound3 = Sample_Load(sMsg);
				break;
				}
		}
		return i;
	}
and these are the warnings i get:

Code: Select all

ghtSound.c: In functie 'SoundLoad':
ghtSound.c:48: let op: passing argument 1 of 'Sample_Load' discards qualifiers from pointer target type
ghtSound.c:52: let op: passing argument 1 of 'Sample_Load' discards qualifiers from pointer target type
ghtSound.c:56: let op: passing argument 1 of 'Sample_Load' discards qualifiers from pointer target type
I can get it to run but then my game crashes when i want to play a sound.

any ideas?
zilt
Posts: 45
Joined: Tue Feb 21, 2006 11:59 pm
Location: Ontario, Canada
Contact:

Post by zilt »

How is your Sample_Load() function declared? Does it included the 'const' qualifier? ie. 'Sample_Load( const char * name )'
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Post by Ghoti »

it like this:

Code: Select all

MIKMODAPI extern SAMPLE *Sample_Load(CHAR*);
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Post by Ghoti »

thanks removed the const and that did the trick :) my game crashes still however :(
zilt
Posts: 45
Joined: Tue Feb 21, 2006 11:59 pm
Location: Ontario, Canada
Contact:

Post by zilt »

My answer was only for the compile warnings - it wouldn't cause your game to crash. Can't help you with the crash. Check the return value from Sample_Load() - is it valid? If you don't play a sound, does it still crash? You have to narrow down the cause of the crash more.
Post Reply