PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > ANSI C?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
ANSI C?

Réponse
 
LinkBack Outils de la discussion
Vieux 05/02/2008, 08h17   #1
Billy Bong
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut ANSI C?

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

  Réponse avec citation
Vieux 05/02/2008, 09h23   #2
Ian Collins
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ANSI C?

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.
  Réponse avec citation
Vieux 05/02/2008, 09h28   #3
Richard
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ANSI C?

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?
  Réponse avec citation
Vieux 05/02/2008, 12h08   #4
Malcolm McLean
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ANSI C?


"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

  Réponse avec citation
Vieux 05/02/2008, 12h14   #5
santosh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ANSI C?

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.

  Réponse avec citation
Vieux 05/02/2008, 12h28   #6
Mark Bluemel
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ANSI C?

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.
  Réponse avec citation
Vieux 06/02/2008, 03h15   #7
Jack Klein
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ANSI C?

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
  Réponse avec citation
Vieux 06/02/2008, 07h08   #8
Billy Bong
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ANSI C?

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



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h36.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12646 seconds with 16 queries