By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,513 Members | 1,810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,513 IT Pros & Developers. It's quick & easy.

cstdlib and stdlib.h problem

P: n/a
Hi,

in a cpp file we are including <cstdliband indirectly including
<stdlib.h>. But the definition for "strtoll" is not appearing in
the .ii file generated using the -E option to gcc.

snippet of .ii file

=========================================
# 307 "/vobs/publish_linux_vob/publish_linux/include/pin_type.h" 2
# 358 "/vobs/publish_linux_vob/publish_linux/include/pin_type.h"
# 1 "/usr/lib/gcc/x86_64-redhat-linux/3.4.6/include/stddef.h" 1 3 4
# 359 "/vobs/publish_linux_vob/publish_linux/include/pin_type.h" 2
# 371 "/vobs/publish_linux_vob/publish_linux/include/pin_type.h"
# 1 "/vobs/publish_linux_vob/publish_linux/include/pin_os_string.h" 1
# 14 "/vobs/publish_linux_vob/publish_linux/include/pin_os_string.h"
# 1 "/usr/include/stdlib.h" 1 3 4
# 33 "/usr/include/stdlib.h" 3 4
# 1 "/usr/lib/gcc/x86_64-redhat-linux/3.4.6/include/stddef.h" 1 3 4
# 34 "/usr/include/stdlib.h" 2 3 4

extern "C" {


# 1 "/usr/include/bits/waitflags.h" 1 3 4
# 43 "/usr/include/stdlib.h" 2 3 4
# 1 "/usr/include/bits/waitstatus.h" 1 3 4
# 65 "/usr/include/bits/waitstatus.h" 3
:
:
:
:
:
# 140 "/usr/include/stdlib.h" 3 4
extern size_t __ctype_get_mb_cur_max (void) throw ();


extern double atof (__const char *__nptr)
throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__
(1)));

extern int atoi (__const char *__nptr)
throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__
(1)));

extern long int atol (__const char *__nptr)
throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__
(1)));

__extension__ extern long long int atoll (__const char *__nptr)
throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__
(1)));

extern double strtod (__const char *__restrict __nptr,
char **__restrict __endptr) throw () __attribute__
((__nonnull__ (1)));

extern float strtof (__const char *__restrict __nptr,
char **__restrict __endptr) throw () __attribute__
((__nonnull__ (1)));

extern long double strtold (__const char *__restrict __nptr,
char **__restrict __endptr)
throw () __attribute__ ((__nonnull__ (1)));
extern long int strtol (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw () __attribute__ ((__nonnull__ (1)));

extern unsigned long int strtoul (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw () __attribute__ ((__nonnull__ (1)));


__extension__
extern long long int strtoq (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw () __attribute__ ((__nonnull__ (1)));

__extension__
extern unsigned long long int strtouq (__const char *__restrict
__nptr,
char **__restrict __endptr, int __base)
throw () __attribute__ ((__nonnull__ (1)));

__extension__
extern long long int strtoq (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw () __attribute__ ((__nonnull__ (1)));

__extension__
extern unsigned long long int strtoull (__const char *__restrict
__nptr,
char **__restrict __endptr, int __base)
throw () __attribute__ ((__nonnull__ (1)));

# 239 "/usr/include/stdlib.h" 3 4
extern long int strtol_l (__const char *__restrict __nptr,
char **__restrict __endptr, int __base,
__locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 4)));

extern unsigned long int strtoul_l (__const char *__restrict __nptr,
char **__restrict __endptr,
int __base, __locale_t __loc)
throw () __attribute__ ((__nonnull__ (1, 4)));

__extension__
extern long long int strtoll_l (__const char *__restrict __nptr,
char **__restrict __endptr, int __base,
__locale_t __loc)
throw () __attribute__ ((__nonnull__ (1, 4)));

__extension__
extern unsigned long long int strtoull_l (__const char *__restrict
__nptr,
char **__restrict __endptr,
int __base, __locale_t __loc)
:
:
:
:
==============================================
Command used to generate the .ii file

gcc -c -I/vobs/rw_rls_unix_vob/rw_rls_unix/ed9/linux_gcc346_32 -I/vobs/
rw_rls_unix_vob/rw_rls_unix/ed9/linux_gcc346_32/include -I../../
include -I/vobs/publish_linux_vob/publish_linux/include -I. -I./
include -I../include -DOS_VER=linux_2.6.9-42.0.0.0.1.ELsmp -
DPIN_USE_ANSI_HDRS -D_REENTRANT -D__unix -D__linux -Dlinux -D__linux__
-DLITTLE_ENDIAN -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -
D_GLIBC_HAVE_LONG_LONG -D__USE_MISC -DLINUX -Dx86 -Dx86_64 -pthread -
Wall -Wno-unused -fPIC -Wno-ctor-dtor-privacy -Wno-reorder -
DINC_TEMPL_DEFS=1 -fpermissive -m32 -g -D_PIN_DEBUG -D_DEBUG -DPUBLIC=
-D_PCM_OPS_H -DTRACE -DRWDEBUG=1 -D_RWSTD_MINIMUM_NEW_CAPACITY=4 -
D_RWSTD_NEW_CAPACITY_RATIO=1.1 -D_RWSTD_MINIMUM_STRING_CAPACITY=16 -
DRW_MULTI_THREAD -DRWSTD_MULTI_THREAD -DRWTRACE=0 -
DRW_USER_TRACE_LEVEL=0 -D_RWCONFIG_15d -DRWLIBVERSION="15d" -
DRW_THR_OS_VERSION_LINUX=0x02609 -
DRW_THR_COMPILER_VERSION_GCC=0x00030404 -D__USE_ISOC99 -E -o
ProcTimeCounteR1.II ProcTimeCounter.cpp

In stdlib.h I can see the code like
=============================================

#if defined __USE_ISOC99 || (defined __GLIBC_HAVE_LONG_LONG && defined
__USE_MISC)
__BEGIN_NAMESPACE_C99
/* Convert a string to a quadword integer. */
__extension__
extern long long int strtoll (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
__THROW __nonnull ((1));
=============================================
So i am using -D__USE_ISOC99 in my compile command. Still its not
working... Please let me know what could be the problem.

PS: If I include the <stdlib.hdirectly into the cpp source file its
working. But I am not sure why it is not including the definition from
the indirectly included <stdlib.h>

May 30 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 30 Maj, 07:42, Subra <mailursu...@gmail.comwrote:
Hi,

in a cpp file we are including <cstdliband indirectly including
<stdlib.h>. But the definition for "strtoll" is not appearing in
the .ii file generated using the -E option to gcc.
[snip]
In stdlib.h I can see the code like
=============================================

#if defined __USE_ISOC99 || (defined __GLIBC_HAVE_LONG_LONG && defined
__USE_MISC)
__BEGIN_NAMESPACE_C99
/* Convert a string to a quadword integer. */
__extension__
extern long long int strtoll (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
__THROW __nonnull ((1));
=============================================
So i am using -D__USE_ISOC99 in my compile command. Still its not
working... Please let me know what could be the problem.
The C library part of C++ is not updated to C99 standards yet. As tho
why using -D__USE_ISOC99 does not work I don't know, it's an
implementation detail, but there might be something in cstdlib that
disables support for C99 features to make sure that it's fully C++
compatible. You'll have to ask in a forum for your implementation for
more details.

--
Erik Wikström

May 30 '07 #2

P: n/a
The C library part of C++ is not updated to C99 standards yet. As tho
why using -D__USE_ISOC99 does not work I don't know, it's an
I tried writing test.cpp
#include<test.hpp>
int main()
{
return 0;
}

and test.hpp with
#include<stdlib.h>

this works fine with
gcc -c -I/vobs/rw_rls_unix_vob/rw_rls_unix/ed9/linux_gcc346_32 -I/vobs/
rw_rls_unix_vob/rw_rls_unix/ed9/linux_gcc346_32/include -I../include -
I/vobs/publish_linux_vob/publish_linux/include -I. -I./include -I../
include -DOS_VER=linux_2.6.9-42.0.0.0.1.ELsmp -DPIN_USE_ANSI_HDRS -
D_REENTRANT -D__unix -D__linux -Dlinux -D__linux__ -DLITTLE_ENDIAN -
D_XOPEN_SOURCE=500 -D_GNU_SOURCE -DLINUX -Dx86 -Dx86_64 -pthread -Wall
-Wno-unused -fPIC -Wno-ctor-dtor-privacy -Wno-reorder -
DINC_TEMPL_DEFS=1 -fpermissive -m32 -g -D_PIN_DEBUG -D_DEBUG -DPUBLIC=
-D_PCM_OPS_H -DTRACE -DRWDEBUG=1 -D_RWSTD_MINIMUM_NEW_CAPACITY=4 -
D_RWSTD_NEW_CAPACITY_RATIO=1.1 -D_RWSTD_MINIMUM_STRING_CAPACITY=16 -
DRW_MULTI_THREAD -DRWSTD_MULTI_THREAD -DRWTRACE=0 -
DRW_USER_TRACE_LEVEL=0 -D_RWCONFIG_15d -DRWLIBVERSION="15d" -
DRW_THR_OS_VERSION_LINUX=0x02609 -
DRW_THR_COMPILER_VERSION_GCC=0x00030404 -DSHLIB_PREFIX="lib" -
DSHLIB_EXT="_dbg.so" -DSCR_INTERNAL -I../../../tools_vob/tools/linux/
flex/include test.cpp
What might be the problem with my actual project ?

May 30 '07 #3

P: n/a
On May 30, 9:10 am, Subra <mailursu...@gmail.comwrote:
The C library part of C++ is not updated to C99 standards yet. As tho
why using -D__USE_ISOC99 does not work I don't know, it's an
I tried writing test.cpp
#include<test.hpp>
int main()
{
return 0;

}
and test.hpp with
#include<stdlib.h>
this works fine with
gcc -c -I/vobs/rw_rls_unix_vob/rw_rls_unix/ed9/linux_gcc346_32 -I/vobs/
rw_rls_unix_vob/rw_rls_unix/ed9/linux_gcc346_32/include -I../include -
I/vobs/publish_linux_vob/publish_linux/include -I. -I./include -I../
include -DOS_VER=linux_2.6.9-42.0.0.0.1.ELsmp -DPIN_USE_ANSI_HDRS -
D_REENTRANT -D__unix -D__linux -Dlinux -D__linux__ -DLITTLE_ENDIAN -
D_XOPEN_SOURCE=500 -D_GNU_SOURCE -DLINUX -Dx86 -Dx86_64 -pthread -Wall
-Wno-unused -fPIC -Wno-ctor-dtor-privacy -Wno-reorder -
DINC_TEMPL_DEFS=1 -fpermissive -m32 -g -D_PIN_DEBUG -D_DEBUG -DPUBLIC=
-D_PCM_OPS_H -DTRACE -DRWDEBUG=1 -D_RWSTD_MINIMUM_NEW_CAPACITY=4 -
D_RWSTD_NEW_CAPACITY_RATIO=1.1 -D_RWSTD_MINIMUM_STRING_CAPACITY=16 -
DRW_MULTI_THREAD -DRWSTD_MULTI_THREAD -DRWTRACE=0 -
DRW_USER_TRACE_LEVEL=0 -D_RWCONFIG_15d -DRWLIBVERSION="15d" -
DRW_THR_OS_VERSION_LINUX=0x02609 -
DRW_THR_COMPILER_VERSION_GCC=0x00030404 -DSHLIB_PREFIX="lib" -
DSHLIB_EXT="_dbg.so" -DSCR_INTERNAL -I../../../tools_vob/tools/linux/
flex/include test.cpp
What might be the problem with my actual project ?
Try asking in a g++ forum. There's (formally) no strtoll
function in C++ (yet). There is in C99, and I expect that most
C++ implementations make it available as an extension, but how
you turn the extension on depends on the implementation. (From
your description so far, I'd guess rather that there is
something in your production environment which turns it off.
But you'd have to ask the g++ experts what.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
May 30 '07 #4

P: n/a
After a lots of lots strugle, I found that there is

#define strtoll strtoq

In one of the 1000 include files.

Thanks for the help... Good lession for the debbuging....

May 31 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.