Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: Linkage

Reply
Thread Tools

Re: Linkage

 
 
BartC
Guest
Posts: n/a
 
      01-30-2013
"James Kuyper" <> wrote in message
news:...
> On 01/30/2013 04:04 PM, BartC wrote:


> dropped the "implicit int" rule. The problem you describe is precisely
> why that change was made. Have you been compiling for C90?


Probably. I don't use any switches except the handful I know about.

> Doubtless there is some switch somewhere or other on my gcc to change this
>> behaviour (but it's usually a major undertaking to find out what it might
>> be).


> -std=c99 -Wall -Wstrict-prototypes -Wmissing-prototypes covers most of
> the possible issues with function prototypes.


Thanks. Although I found that -std=c99 by itself is sufficient to flag
'implicit declarations' of functions. The prototype options didn't seem to
do anything.

One small problem is that c99 mode doesn't like my anonymous unions; it
gives loads of warnings (and usually my compilations are 'clean'; these
would drown out any real problems). But my own research came up with
the -std=gnu99 option which highlights the missing prototype I knew about
(and a couple of dozen I didn't!), without objecting to much else.

--
Bartc

 
Reply With Quote
 
 
 
 
James Kuyper
Guest
Posts: n/a
 
      01-31-2013
On 01/30/2013 05:54 PM, BartC wrote:
> "James Kuyper" <> wrote in message
> news:...
>> On 01/30/2013 04:04 PM, BartC wrote:

>
>> dropped the "implicit int" rule. The problem you describe is precisely
>> why that change was made. Have you been compiling for C90?

>
> Probably. I don't use any switches except the handful I know about.


With no switches set, gcc implements Gnu-C, a language closely related
to C, but it does not actually conform to any version of the C standard.
If you didn't set -ansi or -std=c90 or -std-c99 or -std=c9x or -std=c1x,
discussions about how it behaves are more appropriately carried out in a
forum associated with Gnu-C.

>> Doubtless there is some switch somewhere or other on my gcc to change this
>>> behaviour (but it's usually a major undertaking to find out what it might
>>> be).

>
>> -std=c99 -Wall -Wstrict-prototypes -Wmissing-prototypes covers most of
>> the possible issues with function prototypes.

>
> Thanks. Although I found that -std=c99 by itself is sufficient to flag
> 'implicit declarations' of functions. The prototype options didn't seem to
> do anything.


They only have a visible effect if you create the situation that they're
supposed to warn about. I was recommending those options on general
grounds, not because they help with this particular problem.
-Wstrict-prototypes warns about using non-prototyped function
declarations. -Wmissing-prototypes warns if a global function is defined
without a prototype already in scope - this is intended to encourage the
#inclusion of header files containing the prototype in the same file
with the definition, so you can be sure the prototype in the header is
compatible with the definition. It would be better if it checked whether
the prototype was the result of a #include directive, but presumably
that would have been harder to implement.

> One small problem is that c99 mode doesn't like my anonymous unions; it
> gives loads of warnings (and usually my compilations are 'clean'; these
> would drown out any real problems). But my own research came up with
> the -std=gnu99 option which highlights the missing prototype I knew about
> (and a couple of dozen I didn't!), without objecting to much else.


With that option, you're compiling Gnu-C99, not C99. Those are two
different, but related languages. Anonymous unions are a feature of
Gnu-C99 and C2011, but not of C99. Try -std=c1x, and see if you like the
results any better.
--
James Kuyper
 
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
c++ linkage vs c linkage ramasubramanian.rahul@gmail.com C++ 1 09-12-2008 11:41 AM
TabStrip Control with direct linkage? Sönke Greve ASP .Net 0 01-22-2006 07:33 PM
JNI problem - linkage problems trying to generate DLL for Win32 functions... Mary Java 1 10-11-2004 12:31 PM
Devious linkage to enter Web site Don@NoSpam HTML 3 07-05-2004 09:53 PM
JNI linkage issue Thomas Dorris Java 2 02-02-2004 09:33 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57