|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Is the following program considered ANSI C?
#include <foo/foo_bar.h> /* has prototype void bar(void) */ int main(void) { bar(); return 0; } Thanks -- Billy |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Billy Bong wrote:
> Is the following program considered ANSI C? > Why shouldn't it be? > #include <foo/foo_bar.h> /* has prototype void bar(void) */ > int main(void) > { > bar(); > return 0; > } > > Thanks -- Ian Collins. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Billy Bong <billyb655321@aol.com> writes:
> Is the following program considered ANSI C? > > #include <foo/foo_bar.h> /* has prototype void bar(void) */ > int main(void) > { > bar(); > return 0; > } > > Thanks What does "Thanks" do? |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
"Billy Bong" <billyb655321@aol.com> wrote in message > Is the following program considered ANSI C? > > #include <foo/foo_bar.h> /* has prototype void bar(void) */ > int main(void) > { > bar(); > return 0; > } > Depends what you mean. The language itself will almost certainly be ANSI C89. However you are including a non-standard header. bar() itself could be implemented in any language that provides facilities for C-style linking, and may or may not be portable. -- Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Malcolm McLean wrote:
> > "Billy Bong" <billyb655321@aol.com> wrote in message >> Is the following program considered ANSI C? >> >> #include <foo/foo_bar.h> /* has prototype void bar(void) */ >> int main(void) >> { >> bar(); >> return 0; >> } >> > Depends what you mean. > > The language itself will almost certainly be ANSI C89. IME most C compilers seem to have implemented changes upto at least C95 with portions of C99. > However you are > including a non-standard header. bar() itself could be implemented in > any language that provides facilities for C-style linking, and may or > may not be portable. Perhaps the OP is asking whether the forward slash in the header name is portable. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
santosh wrote:
> Malcolm McLean wrote: > >> "Billy Bong" <billyb655321@aol.com> wrote in message .... > Perhaps the OP is asking whether the forward slash in the header name is > portable. It's hard to know what the OP is interested in. My impression is that he is mainly interested in increasing the noise-to-signal ratio here, so I killfiled him some time ago. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Tue, 05 Feb 2008 08:17:58 GMT, Billy Bong <billyb655321@aol.com>
wrote in comp.lang.c: > Is the following program considered ANSI C? The following is NOT a program. > #include <foo/foo_bar.h> /* has prototype void bar(void) */ > int main(void) > { > bar(); > return 0; > } > > Thanks What it is, together with the contents of "foo/foo_bar.h", plus the inclusion of anything else that might be indicated by preprocessor inclusion directives in "foo/foo_bar.h", is a "translation unit". Once it has been compiled and combined with other appropriate separately compiled translation units, it might become a program. The part of the program you have shown is conforming, and it might or might not be strictly conforming. There is no such thing as an "ANSI C" program. -- Jack Klein Home: http://JK-Technology.Com FAQs for comp.lang.c http://c-faq.com/ comp.lang.c++ http://www.parashift.com/c++-faq-lite/ alt.comp.lang.learn.c-c++ http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On Tue, 05 Feb 2008 21:15:39 -0600, Jack Klein wrote:
> On Tue, 05 Feb 2008 08:17:58 GMT, Billy Bong <billyb655321@aol.com> > wrote in comp.lang.c: > >> Is the following program considered ANSI C? > > The following is NOT a program. In other words, your answer to my question is "NO"? >> #include <foo/foo_bar.h> /* has prototype void bar(void) */ int >> main(void) >> { >> bar(); >> return 0; >> } >> >> Thanks > > What it is, together with the contents of "foo/foo_bar.h", plus the > inclusion of anything else that might be indicated by preprocessor > inclusion directives in "foo/foo_bar.h", is a "translation unit". My example used <foo/foo_bar.h>, not "foo/foo_bar.h", as you stated. I assume this difference does not matter? > Once it has been compiled and combined with other appropriate separately > compiled translation units, it might become a program. In other words, now your answer to my question is "MAYBE"? > The part of the program you have shown is conforming, and it might or > might not be strictly conforming. There is no such thing as an "ANSI C" > program. So what you're saying is that the following is not an "ANSI C" program either? /* foo.c */ #include <stdio.h> int main(void) { char s[16]; gets(s); return 0; } It compiles, links, and "runs" just fine with gcc under Linux. gcc -Wall -W -ansi -pedantic -o foo foo.c ../foo Now I'm confused about what is and what is not an "ANSI C" program, or even if such a thing exists. I thought the "-ansi" option in the above, combined with the "-o" option, should have given me an "ANSI C" program, if everything compiles and links without errors (which it did). Are you saying that this is not true? And if so, isn't gcc kinda, sorta, lying to me? I seek the truth and nothing but the truth. Thanks in advance -- Billy |
|
![]() |
| Outils de la discussion | |
|
|