warning in "switch,case"

Hi
In my program I have one warning that I did not find reason of this warning:

my code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
int next_option;
do {
	 next_option = getopt_long(argc,argv,short_option,long_option,NULL);

	 switch (next_option)
	 {
	 case 'h':
		 Print_Usage(stdout,0);
	 case 'o':
		 output_name = optarg;
		 break;
.	 case 'v':
.		 verbose = 1;
.		 break;
.	 case '?':
10-		 Print_Usage(stderr,1);
11-	 case '-1':
12-		 break;
.	 default:
.		 abort();
.	 }
 }
 while (next_option != -1);


I get this warning :
multi-character character constant for line 11.

Thanks in advance
It's warning you that '-1' is not a char nor a string, it's an int written with the multi-character literal, which is usually not what you want.
( Notice: -1 != '-1' != "-1" )
Last edited on
Hey,

If you want to say -1, just write => -1 (no need for '' or " ")
closed account (zb0S216C)
You're missing a break; clause at the end of the first case, another break; at the end of the 4th case and another at the end of the default case.

Characters or chars are single characters only, where '-1' contains multiple characters, which is not valid. In the last line: while (next_option != -1), you're comparing the character's integer equivalent, not the character itself.
Hi
Thanks a lot for your attention and good reply :)
With your solution my problem was solved.

Topic archived. No new replies allowed.