Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > How would you resolve this symbol conflict?

Reply
Thread Tools

How would you resolve this symbol conflict?

 
 
metaperl.j@gmail.com
Guest
Posts: n/a
 
      11-12-2007
Compilation error:

make
gcc -O -c -o a.o a.c
In file included from j.h:39,
from a.c:14:
je.h:191: error: 'nan' redeclared as different kind of symbol
/usr/include/math.h:177: error: previous declaration of 'nan' was here

je.h declares nan as extern D where type is typedef double D

math.h declares nan as:
extern double nan _PARAMS((const char *));

nan is only used in a few places in the code:

find . -type f -print0 | xargs -0 -e grep -nH -e nan
../i.c:77: MC(&nan,XNAN,(size_t)sizeof(D));
../j.c:31 nan;
../je.h:191:extern D nan;
../je.h-:193:extern D nan;
../wn.c:20: if('-'==*s&&3>n){x=1==n?infc=*(1+s),c=='-')?-inf:c=='.'?
nan:0; if(x){*v=x; R 1;}}

So I'm wondering what technique would be best to rename all the nan
calls in the code to something else to avoid conflicts. Perhaps some
sort of #define is in order.

 
Reply With Quote
 
 
 
 
Ben Bacarisse
Guest
Posts: n/a
 
      11-12-2007
"(E-Mail Removed)" <(E-Mail Removed)> writes:

> Compilation error:
>
> make
> gcc -O -c -o a.o a.c
> In file included from j.h:39,
> from a.c:14:
> je.h:191: error: 'nan' redeclared as different kind of symbol
> /usr/include/math.h:177: error: previous declaration of 'nan' was here
>
> je.h declares nan as extern D where type is typedef double D
>
> math.h declares nan as:
> extern double nan _PARAMS((const char *));
>
> nan is only used in a few places in the code:
>
> find . -type f -print0 | xargs -0 -e grep -nH -e nan
> ./i.c:77: MC(&nan,XNAN,(size_t)sizeof(D));
> ./j.c:31 nan;
> ./je.h:191:extern D nan;
> ./je.h-:193:extern D nan;
> ./wn.c:20: if('-'==*s&&3>n){x=1==n?infc=*(1+s),c=='-')?-inf:c=='.'?
> nan:0; if(x){*v=x; R 1;}}


You may want to remove the two useless spaces in that line that are
helping readability at the expense of wasted bytes. Also:

if(x)R *v=x,1;

might work to remove one set of those pesky {}s.

Seriously, you may want to reconsider your coding guidelines.

> So I'm wondering what technique would be best to rename all the nan
> calls in the code to something else to avoid conflicts. Perhaps some
> sort of #define is in order.


I'd rename your nan (since it occurs so infrequently) rather the
trying to move the standard one off to one side.

--
Ben.
 
Reply With Quote
 
 
 
 
metaperl.j@gmail.com
Guest
Posts: n/a
 
      11-12-2007
On Nov 12, 6:58 am, Ben Bacarisse <(E-Mail Removed)> wrote:
> "(E-Mail Removed)" <(E-Mail Removed)> writes:
> > Compilation error:

>
> > make
> > gcc -O -c -o a.o a.c
> > In file included from j.h:39,
> > from a.c:14:
> > je.h:191: error: 'nan' redeclared as different kind of symbol
> > /usr/include/math.h:177: error: previous declaration of 'nan' was here

>
> > je.h declares nan as extern D where type is typedef double D

>
> > math.h declares nan as:
> > extern double nan _PARAMS((const char *));

>
> > nan is only used in a few places in the code:

>
> > find . -type f -print0 | xargs -0 -e grep -nH -e nan
> > ./i.c:77: MC(&nan,XNAN,(size_t)sizeof(D));
> > ./j.c:31 nan;
> > ./je.h:191:extern D nan;
> > ./je.h-:193:extern D nan;
> > ./wn.c:20: if('-'==*s&&3>n){x=1==n?infc=*(1+s),c=='-')?-inf:c=='.'?
> > nan:0; if(x){*v=x; R 1;}}

>
> You may want to remove the two useless spaces in that line that are
> helping readability at the expense of wasted bytes.




This is not my code. It is an early open source version of the J
programming language:
ftp://ftp.gaertner.de/pub/j/j-v7-src.tgz


>
> > So I'm wondering what technique would be best to rename all the nan
> > calls in the code to something else to avoid conflicts. Perhaps some
> > sort of #define is in order.

>
> I'd rename your nan (since it occurs so infrequently) rather the
> trying to move the standard one off to one side.


Ok. thanks. I will do that.

 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      11-12-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Compilation error:
>
> make
> gcc -O -c -o a.o a.c
> In file included from j.h:39,
> from a.c:14:
> je.h:191: error: 'nan' redeclared as different kind of symbol
> /usr/include/math.h:177: error: previous declaration of 'nan' was here
>
> je.h declares nan as extern D where type is typedef double D
>
> math.h declares nan as:
> extern double nan _PARAMS((const char *));
> [...]


It's not supposed to do that; <math.h> is not allowed to
declare `nan' at all. The gcc compiler is famous/notorious
for compiling "C with extras" in its default mode of operation;
try running it in a conforming mode with

gcc -ansi -pedantic ...
or
gcc -std=whatever -pedantic ...

.... and see if that suppresses the gratuitous `nan' declaration.

--
Eric Sosman
(E-Mail Removed)lid
 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      11-12-2007
Eric Sosman <(E-Mail Removed)> writes:

> (E-Mail Removed) wrote:
>> Compilation error:
>>
>> make
>> gcc -O -c -o a.o a.c
>> In file included from j.h:39,
>> from a.c:14:
>> je.h:191: error: 'nan' redeclared as different kind of symbol
>> /usr/include/math.h:177: error: previous declaration of 'nan' was here
>>
>> je.h declares nan as extern D where type is typedef double D
>>
>> math.h declares nan as:
>> extern double nan _PARAMS((const char *));
>> [...]

>
> It's not supposed to do that; <math.h> is not allowed to
> declare `nan' at all.


Eh? double nan(const char *); is in C99. I can't see how it could
avoid declaring it but, since I have not know you to be wrong, I await
being corrected!

--
Ben.
 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      11-12-2007
Ben Bacarisse wrote On 11/12/07 09:52,:
> Eric Sosman <(E-Mail Removed)> writes:
>
>
>>(E-Mail Removed) wrote:
>>
>>>Compilation error:
>>>
>>>make
>>>gcc -O -c -o a.o a.c
>>>In file included from j.h:39,
>>> from a.c:14:
>>>je.h:191: error: 'nan' redeclared as different kind of symbol
>>>/usr/include/math.h:177: error: previous declaration of 'nan' was here
>>>
>>>je.h declares nan as extern D where type is typedef double D
>>>
>>>math.h declares nan as:
>>>extern double nan _PARAMS((const char *));
>>>[...]

>>
>> It's not supposed to do that; <math.h> is not allowed to
>>declare `nan' at all.

>
>
> Eh? double nan(const char *); is in C99. I can't see how it could
> avoid declaring it but, since I have not know you to be wrong, I await
> being corrected!


Ben, I really wish you'd stop arguing with me when
I have egg all over my face. Just because I'm wrong,
R-O-N-G wrong, is no excuse for you to be right.

(In other words, the reports of my infallibility have
been greatly exaggerated. Thanks for the correction.)

--
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
src-resolve: Cannot resolve the name ... ivanet@gmail.com XML 1 03-23-2007 12:10 PM
Cannot resolve symbol Jo Java 3 04-10-2004 06:12 PM
Re: Cannot resolve Symbol (class) but why? (JSP) @lex-kid Java 2 07-07-2003 07:26 AM
Re: Cannot resolve Symbol (class) but why? (JSP) sufia Java 1 07-06-2003 07:06 PM



Advertisments