C Questions

S

santosh

No. The '-ansi' or '-std=c89' switches do that. The '-pedantic'
switch tells gcc to conform to the relevant language dialect as
strictly as possible.

No, the -ansi (or as you say, -std=c89) and -pedantic options are
_both_ required for gcc to attempt to conform to C89. The -ansi flag
makes sure valid programs are accepted, and the -pedantic flag makes
sure invalid programs are diagnosed. If either option is omitted, the
compiler, while perhaps useful, isn't conforming to C89/C90.

You can use see from these examples:

int main(int argc, char *argv[]) {
int typeof; /* valid declaration, must be accepted */
return 0;
}

int main(int argc, char *argv[]) {
int array[argc+1]; /* a diagnostic is required in C90 */
return 0;
}

Thanks. Now that I read the gcc manual more closely, you're right.
 
D

dj3vande

Philip Potter wrote:

I agree - the standard is a lousy textbook, but a good reference work. I
haven't needed a textbook for C for a couple of decades, so I can't give
any current recommendations along those lines, but the text book I used
several decades ago was K&R, 1st edition, and it was excellent.

The second edition is the textbook I used a decade and a bit ago, and
it's not only excellent but also much more useful these days for
anything other than historical interest.


dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,167
Latest member
SusanaSwan
Top