473,404 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

ifdef

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
Jul 4 '06 #1
1 3192
Michael Sgier wrote:
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
Jul 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Christopher M. Lusardi | last post by:
Hello, Is there anyway to do it other than using : #ifdef VAR1 ... #endif
5
by: lovecreatesbeauty | last post by:
Do #ifdef or #ifndef have some defects? I ever heard that some people use #if defined() or #if !defined() instead of using #ifdef or #ifndef in header file.
5
by: Hash | last post by:
I have a small doubt, #ifdef _BSD When we use #ifdef preprocessor directive, the parameter which we pass (in this case _BSD) is it defined by the user or is it defined somewhere else? If...
6
by: Michael B Allen | last post by:
Which is the preferred method for preprocessor tests and why? #ifdef XYZ or #if XYZ or #if defined(XYZ) and
8
by: kk_oop | last post by:
Hi. In our domain, we have to vary a lot of code based on a radar type (of which there are 3--for now). The legacy code acheives this by heavy use of #ifdef macros sprinkled throughout the code. ...
5
by: anushhprabu | last post by:
#include <stdio.h> #include <ctype.h> #define DEBUG 1 main() { char inbuf; int i = 0; int lcnt = 0; gets(inbuf); while(*(inbuf+i))
6
by: anirbid.banerjee | last post by:
Hi, I need to write a macro which would have a lot many conditional #ifdef ... #endif blocks in it. #define _xx_macro (x) { ... \ ... \ /* some code (); */ #ifdef _SOME_STMT \ ... \ ... \
10
by: David W | last post by:
Hello, In a C++ MFC application I need to conditionally #include one of two additional resource files in my main resource file because different forms of the application have different names. I...
3
by: Andrew Gabriel | last post by:
I want to pick up the OS release during compilation in order to make up for something which is missing from a header file in a certain release. The Sun C compiler provides a built in predefinition...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.