ifdef

M

Michael Sgier

Hi
I get the error:
No case-independent string comparison (stricmp, strcasecmp)
with the code below. Why...where should stricmp
be defined? And how do i get rid of the error on Linux?

//
// Function portability
//
#ifndef HAVE_STRICMP
#ifdef HAVE_STRCASECMP
#define stricmp strcasecmp
#else
#error No case-independent string comparison (stricmp, strcasecmp)
available.
#endif
#endif // HAVE_STRICMP


another problem here:


#define DEBUG 1
main()
{
char inbuf[BUFSIZ];
int i = 0;
int lcnt = 0;
gets(inbuf);
while(*(inbuf+i))
{
#ifdef DEBUG
printf("Character %d Value %c(%o)\n",
i,*(inbuf+i),*(inbuf+i));
#endif
if(isalpha(*(inbuf+i)))lcnt++;
#ifdef DEBUG
printf("Letter Count %d\n",lcnt);
#endif
i++;
}
printf("Total letters %d\n",lcnt);
}


why is ifdef DEBUG 2x there?
Thanks
Michael
 
L

Larry I Smith

Michael said:
Hi
I get the error:
No case-independent string comparison (stricmp, strcasecmp)
with the code below. Why...where should stricmp
be defined? And how do i get rid of the error on Linux?

//
// Function portability
//
#ifndef HAVE_STRICMP
#ifdef HAVE_STRCASECMP
#define stricmp strcasecmp
#else
#error No case-independent string comparison (stricmp, strcasecmp)
available.
#endif
#endif // HAVE_STRICMP


another problem here:


#define DEBUG 1
main()
{
char inbuf[BUFSIZ];
int i = 0;
int lcnt = 0;
gets(inbuf);
while(*(inbuf+i))
{
#ifdef DEBUG
printf("Character %d Value %c(%o)\n",
i,*(inbuf+i),*(inbuf+i));
#endif
if(isalpha(*(inbuf+i)))lcnt++;
#ifdef DEBUG
printf("Letter Count %d\n",lcnt);
#endif
i++;
}
printf("Total letters %d\n",lcnt);
}


why is ifdef DEBUG 2x there?
Thanks
Michael

This is not a C++ question.
You'll get more detailed answers in the GCC newsgroup:

gnu.gcc.help

On my linux system with gcc v3.3.5 strcasecmp()
is declared in strings.h, but HAVE_STRCASECMP is NOT
defined. This looks like part of an automake/config
system where automake sets the defines (eg HAVE_STRCASECMP)
based on its inspection of your system. If you do
have strcasecmp() in /usr/include/strings.h you can
define HAVE_STRCASECMP yourself.

Regards,
Larry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top