how to deal with stdlib.h
Author |
Message |
wantohi #1 / 8
|
 how to deal with stdlib.h
when i compile my project today,gcc report the error as follow: In file included from /usr/include/bits/string2.h:1176, from /usr/include/string.h:360, from /home/source/include/port.h:53, /usr/include/stdlib.h:527: parse error before `(' /usr/include/stdlib.h:529: parse error before `(' the 512 line of /usr/include/stdlib.h is /* Allocate SIZE bytes of memory. */ extern void *malloc (size_t __size) __THROW __attribute_malloc__; /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ extern void *calloc (size_t __nmemb, size_t __size) __THROW __attribute_malloc__; pls tell me what is lead to occuer this problem
|
Fri, 26 Nov 2004 18:36:22 GMT |
|
 |
Richard B #2 / 8
|
 how to deal with stdlib.h
Quote:
> when i compile my project today,gcc report the error as follow: > In file included from /usr/include/bits/string2.h:1176, > from /usr/include/string.h:360, > from /home/source/include/port.h:53, > /usr/include/stdlib.h:527: parse error before `(' > /usr/include/stdlib.h:529: parse error before `(' > the 512 line of /usr/include/stdlib.h is
Are you sure you don't mean 527th? Quote: > /* Allocate SIZE bytes of memory. */ > extern void *malloc (size_t __size) __THROW __attribute_malloc__;
There is no problem with this line /per se/, provided the reserved keywords __THROW and __attribute_malloc__ decode to something your implementation understands. Then again, perhaps that's just the problem: are you sure you're using the right header files with the right compiler? Alternatively, something may be wrong on the lines before these. But I'd be wary of messing with the implementation's Standard header files - better check and make backups before you change anything. Richard
|
Fri, 26 Nov 2004 19:17:36 GMT |
|
 |
Richard Heathfiel #3 / 8
|
 how to deal with stdlib.h
Quote:
> when i compile my project today,gcc report the error as follow: > In file included from /usr/include/bits/string2.h:1176, > from /usr/include/string.h:360, > from /home/source/include/port.h:53, > /usr/include/stdlib.h:527: parse error before `(' > /usr/include/stdlib.h:529: parse error before `(' > the 512 line of /usr/include/stdlib.h is > /* Allocate SIZE bytes of memory. */ > extern void *malloc (size_t __size) __THROW __attribute_malloc__; > /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ > extern void *calloc (size_t __nmemb, size_t __size) > __THROW __attribute_malloc__; > pls tell me what is lead to occuer this problem
The problem is unlikely to be with your headers, unless you have been messing with them. It's more likely to be a problem with your source code, which we can't see. Even if it is a problem with your headers, showing us lines 512-516 of your header won't help us to help you if the compiler reports that the problems are on lines 527 and 529. My guess - your source code called a macro, but the call is wrong. Solution: fix your code, or present to this newsgroup the smallest compilable program that exhibits the problem. --
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999. C FAQ: http://www.eskimo.com/~scs/C-faq/top.html K&R answers, C books, etc: http://users.powernet.co.uk/eton
|
Fri, 26 Nov 2004 20:11:46 GMT |
|
 |
Dan P #4 / 8
|
 how to deal with stdlib.h
Quote: >Solution: fix your code, or present to this newsgroup the smallest
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Quote: >compilable program that exhibits the problem.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ And show us the exact compilation command that produced those diagnostics. Dan -- Dan Pop DESY Zeuthen, RZ group
|
Fri, 26 Nov 2004 21:41:28 GMT |
|
 |
Mark McIntyr #5 / 8
|
 how to deal with stdlib.h
Quote: >when i compile my project today,gcc report the error as follow: >In file included from /usr/include/bits/string2.h:1176, > from /usr/include/string.h:360,
9999 times out of 10000 this problem is absolutely nothing to do wth the standard header. Check your own code just before and just after you #include stdlib.h, especially any nonstandard headers. I bet you find a missing semicolon, nor missing definition of some type. -- Mark McIntyre CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
|
Sat, 27 Nov 2004 06:12:48 GMT |
|
 |
wantohi #6 / 8
|
 how to deal with stdlib.h
Quote:
> > when i compile my project today,gcc report the error as follow: > > In file included from /usr/include/bits/string2.h:1176, > > from /usr/include/string.h:360, > > from /home/source/include/port.h:53, > > /usr/include/stdlib.h:527: parse error before `(' > > /usr/include/stdlib.h:529: parse error before `(' > > the 512 line of /usr/include/stdlib.h is > Are you sure you don't mean 527th? > > /* Allocate SIZE bytes of memory. */ > > extern void *malloc (size_t __size) __THROW __attribute_malloc__; > There is no problem with this line /per se/, provided the reserved > keywords __THROW and __attribute_malloc__ decode to something your > implementation understands. > Then again, perhaps that's just the problem: are you sure you're using > the right header files with the right compiler? > Alternatively, something may be wrong on the lines before these. But I'd > be wary of messing with the implementation's Standard header files - > better check and make backups before you change anything. > Richard
sorry , it should be 527 line of /usr/include/stdlib.h
|
Sat, 27 Nov 2004 08:50:15 GMT |
|
 |
wantohi #7 / 8
|
 how to deal with stdlib.h
Quote:
> >Solution: fix your code, or present to this newsgroup the smallest > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > >compilable program that exhibits the problem. > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > And show us the exact compilation command that produced those > diagnostics. > Dan
my project is a very great,it was planed to compile on redhat6.2.but now i compile it on redhat7.2 and the gcc's version is 2.96! ofcourse my /home/source/include/port.h:53 is : #include <string.h> when occuer this problem, it seems to me that stdlib.h must be is right,but the 527 is : * Allocate SIZE bytes of memory. */ extern void *malloc (size_t __size) __THROW __attribute_malloc__; /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ extern void *calloc (size_t __nmemb, size_t __size) __THROW __attribute_malloc__; ,so i think in my project there must be a header file with a declare of function malloc,i 'grep -rn '\*malloc' /home/source',the result is home/source/lib/iq_1/iq_ytab.c:772: extern char *malloc(); home/source/Util/imake/imake.c:773: char *p, *malloc(); as you have seen ,there no defiune of function malloc. thanx any quick respones
|
Sat, 27 Nov 2004 09:24:38 GMT |
|
 |
Crystal Jacob #8 / 8
|
 how to deal with stdlib.h
Quote:
> my project is a very great,it was planed to compile on redhat6.2.but > now i compile it on redhat7.2 and the gcc's version is 2.96!
You shouldn't be using gcc 2.96. See this URL: http://gcc.gnu.org/gcc-2.96.html If possible, I recommend you upgrade to a less broken gcc (and possibly glibc?) Quote: > when occuer this problem, it seems to me that stdlib.h must be is > right,but the 527 is : > * Allocate SIZE bytes of memory. */ > extern void *malloc (size_t __size) __THROW __attribute_malloc__;
[snip] Quote: > ,so i think in my project there must be a header file with a declare > of function malloc,i 'grep -rn '\*malloc' /home/source',the result is > home/source/lib/iq_1/iq_ytab.c:772: extern char *malloc(); > home/source/Util/imake/imake.c:773: char *p, *malloc();
You really shouldn't be declaring malloc that way. You're telling the compiler there's a function called malloc which returns char *, but the function in the standard C library returns void *. I'm not sure if this is the cause of your problems or not, though. If you #include <stdlib.h>, you won't have to provide your own declaration of malloc. --
|
Sat, 27 Nov 2004 16:12:42 GMT |
|
|
|