Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Which lib to include in my build to use 'isascii' (ctype.h)?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 CaptainMurphy   Members   -  Reputation: 262

Like
0Likes
Like

Posted 17 May 2012 - 12:31 PM

Hi,
I'm trying to compile (with mingw) some code using a library (clang), which in turn requires the use of 'isascii'.


But on making it I get the error message:
'isascii' was not declared in this scope

Which I've been solving a lot of similar errors of functions not being found by figuring out the lib name required to be included (e.g: in the compile call: g++ myprog.cpp -o myprog.exe -lsomelib -lsomeotherlib).

But in this case I'm at a loss at what is required. Various documentation pages on isascii mention it is included with 'ctype.h' but mentions nothing on what library is required for it.

So anyone know if there is a commandline or a library that I need to include with my g++ call, thanks.

Sponsor:

#2 ApochPiQ   Moderators   -  Reputation: 17407

Like
1Likes
Like

Posted 17 May 2012 - 01:22 PM

That's a compiler error, which means you need to change the source code. A linker error would be different, and would be solvable by adding a library.

ctype.h should be part of the standard library distributed with the compiler, and it should know enough to link in the appropriate libs for it if you have the code compiling cleanly.

#3 Bregma   Crossbones+   -  Reputation: 5920

Like
1Likes
Like

Posted 17 May 2012 - 01:58 PM

isascii() is a POSIX (X/Open) function originating in both BSD and System V Unix. It is not a standard C function.

My guess is that in order to get the symbol into visible scope in a mingw environment when using either the GCC or Clang compilers, you will need to #define either _BSD_SOURCE, _SVID_SOURCE, or _XOPEN_SOURCE before #including <ctype.h> in your source. This is just a guess, reading <ctype.h> will probably reveal the ultimate truth.

It may be the case that the C runtime library does not provide any implementation of isascii() in the mingw environment (which should be using the Microsoft C runtime), in which case you're just simply out of luck. Try to use one of the standard character classification functions instead, you may just find they do a better job at whatever you're trying to do.
Stephen M. Webb
Professional Free Software Developer

#4 CaptainMurphy   Members   -  Reputation: 262

Like
0Likes
Like

Posted 17 May 2012 - 02:00 PM

That's a compiler error, which means you need to change the source code. A linker error would be different, and would be solvable by adding a library.

What confuses me is that the error points to a body of a function which is calling isascii, from within a header of the clang library, which compiled successfully (thereby not running into the same problem). Does that mean when a header file has functions with a body (as opposed to bodyless decl like "void func();") that it will be compiled into the program including the header, rather than just linking to it in whatever library the header comes from?

ctype.h should be part of the standard library distributed with the compiler, and it should know enough to link in the appropriate libs for it if you have the code compiling cleanly.

Thanks, that got me thinking about my compile options and I removed '-std=c++0x', which fixed that.

#5 Aardvajk   Crossbones+   -  Reputation: 8266

Like
1Likes
Like

Posted 17 May 2012 - 04:02 PM

Does that mean when a header file has functions with a body (as opposed to bodyless decl like "void func();") that it will be compiled into the program including the header, rather than just linking to it in whatever library the header comes from?


Yep. #include is a literal text-replace and anything the compiler sees will be compiled. The compiler has no idea what library "a header comes from". In fact, the compiler doesn't even know what a header is - the preprocessor takes care of that and is a very simple beast. The compiler just sees a translation unit - one text file.

#6 CaptainMurphy   Members   -  Reputation: 262

Like
0Likes
Like

Posted 17 May 2012 - 08:33 PM

I see, that makes sense, thanks.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS