Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #41358

Re: complex declarations

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: complex declarations
Date 2014-03-04 14:04 -0800
Organization None to speak of
Message-ID <lnob1lwrgy.fsf@nuthaus.mib.org> (permalink)
References <lf5cdv$dll$1@dont-email.me> <53163C3C.8060203@verizon.net> <lf5hca$oqi$1@dont-email.me>

Show all headers | View raw


Robbie Brown <dac@nomail.invalid> writes:
> On 04/03/14 20:49, James Kuyper wrote:
>> On 03/04/2014 03:18 PM, Robbie Brown wrote:
>>> I have the following code
>
> <snip>
>
>> C function definitions can only occur at file scope (6.9p1). You can
>> declare a function at block scope (6.8p2), but you can't define it
>> there. Because you can't define it with block scope, I also personally
>> feel it's a bad idea to declare it at file scope - but that's just a
>> personal preference, not a C rule.
>>
>> If you got this code to compile (except for the part you're asking
>> about), then you're taking advantage of a non-conforming extension to C
>> which allows block scope definitions of functions.
>
> I used gcc -std=c99 complexdecl.c and you are right. Apparently the 
> ability to define a function within a function (nesting of functions) is 
> a gcc extension, sheesh, you really gotta be on the ball with this stuff 
> haven't you?

Use "gcc -std=c99 -pedantic" to make it warn about violations of the C99
standard.  gcc is not a conforming C compiler without the "-pedantic"
option.  Use "-pedantic-warnings" to turn those warnings into fatal
errors.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-04 20:18 +0000
  Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-04 15:49 -0500
    Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-04 16:06 -0500
      Re: complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-05 12:18 +0000
        Re: complex declarations "BartC" <bc@freeuk.com> - 2014-03-05 12:56 +0000
          Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-05 08:24 -0500
            Re: complex declarations "BartC" <bc@freeuk.com> - 2014-03-05 16:26 +0000
        Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-05 08:13 -0500
          Re: complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-05 13:32 +0000
        Re: complex declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-05 14:32 +0000
    Re: complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-04 21:42 +0000
      Re: complex declarations Keith Thompson <kst-u@mib.org> - 2014-03-04 14:04 -0800
        Re: complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-05 09:22 +0000
          Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-05 07:29 -0500
            Re: complex declarations Keith Thompson <kst-u@mib.org> - 2014-03-05 08:38 -0800
      Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-04 17:05 -0500
  Re: complex declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-04 21:15 +0000
    Re: complex declarations "BartC" <bc@freeuk.com> - 2014-03-04 21:38 +0000
      Re: complex declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-04 23:27 +0000
    Re: complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-04 21:59 +0000
      Re: complex declarations James Kuyper <jameskuyper@verizon.net> - 2014-03-04 17:12 -0500
      Re: complex declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-05 00:28 +0000
        Re: complex declarations Robbie Brown <dac@nomail.invalid> - 2014-03-05 09:10 +0000
          Re: complex declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-05 11:44 +0000

csiph-web