is -pedantic bad flag?

N

new to c

Hi!

I write this code cos.c

#include <math.h>
#include <stdio.h>

int main(void)
{
double c;
c = cos(0);
printf("cos(0): %f\n", c);
return 0;
}

I compile normal and it work.

I compile with -pedantic and it not work.

Is -pedantic bad flag?

Is code bug?

I use lcc -pedantic cos.c and he warn

Error cos.c: c:\lcc\include\math.h: 36 Syntax error; missing semicolon before `_cosl'
Warning cos.c: c:\lcc\include\math.h: 36 no type specified. Defaulting to int
Error cos.c: c:\lcc\include\math.h: 99 Syntax error; missing semicolon before `fabsl'
Warning cos.c: c:\lcc\include\math.h: 99 no type specified. Defaulting to int
Error cos.c: c:\lcc\include\math.h: 100 redefinition of '_stdcall'
Error cos.c: c:\lcc\include\math.h: 99 Previous definition of '_stdcall' here
Error cos.c: c:\lcc\include\math.h: 100 Syntax error; missing semicolon before `fabsd'
Warning cos.c: c:\lcc\include\math.h: 100 no type specified. Defaulting to int
Error cos.c: c:\lcc\include\math.h: 101 redefinition of '_stdcall'
Error cos.c: c:\lcc\include\math.h: 100 Previous definition of '_stdcall' here
Error cos.c: c:\lcc\include\math.h: 101 Syntax error; missing semicolon before `fabsf'
Warning cos.c: c:\lcc\include\math.h: 101 no type specified. Defaulting to int
Error cos.c: c:\lcc\include\math.h: 103 redefinition of '_stdcall'
Error cos.c: c:\lcc\include\math.h: 101 Previous definition of '_stdcall' here
Error cos.c: c:\lcc\include\math.h: 103 Syntax error; missing semicolon before `_fabsi'
Warning cos.c: c:\lcc\include\math.h: 103 no type specified. Defaulting to int
Error cos.c: c:\lcc\include\math.h: 104 Syntax error; missing semicolon before `_fabsull'
Warning cos.c: c:\lcc\include\math.h: 104 no type specified. Defaulting to int
Error cos.c: c:\lcc\include\math.h: 105 Syntax error; missing semicolon before `_fabsll'
Warning cos.c: c:\lcc\include\math.h: 105 no type specified. Defaulting to int
Error cos.c: c:\lcc\include\math.h: 106 Syntax error; missing semicolon before `_fabsu'
Warning cos.c: c:\lcc\include\math.h: 106 no type specified. Defaulting to int
Error cos.c: c:\lcc\include\math.h: 272 redefinition of '_stdcall'
Error cos.c: c:\lcc\include\math.h: 106 Previous definition of '_stdcall' here
Error cos.c: c:\lcc\include\math.h: 272 Syntax error; missing semicolon before `_signbit'
Warning cos.c: c:\lcc\include\math.h: 272 no type specified. Defaulting to int
Error cos.c: c:\lcc\include\math.h: 346 redefinition of '_stdcall'
Error cos.c: c:\lcc\include\math.h: 272 Previous definition of '_stdcall' here
Error cos.c: c:\lcc\include\math.h: 346 Syntax error; missing semicolon before `_rint'
Warning cos.c: c:\lcc\include\math.h: 346 no type specified. Defaulting to int
Error cos.c: c:\lcc\include\tgmath.h: 30 too many errors

Is better not use -pedantic? People say -pedantic is good.
 
M

Martin Ambuhl

new said:
Hi!

I write this code cos.c

#include <math.h>
#include <stdio.h>

int main(void)
{
double c;
c = cos(0);
printf("cos(0): %f\n", c);
return 0;
}

I compile normal and it work.

I compile with -pedantic and it not work.

Is -pedantic bad flag?

With a working compiler and a clean library using -pedantic (or its
equivalent) is a good thing. -pedantic with gcc will cause a problem
with the above.
Is code bug?
No.


I use lcc -pedantic cos.c and he warn

It seems that there is something wrong with the lcc implementation, then.
Error cos.c: c:\lcc\include\math.h: 36 Syntax error; missing semicolon before `_cosl'

And this (and similar messages I have not quoted) suggests that the
Is better not use -pedantic? People say -pedantic is good.

Normally, -pedantic is a good thing to use. It appears that using your
copy of lcc is a bad idea. It is possible that the current versions, or
even yours installed correctly, will not have this problem. Check the
lcc (or lcc-win32, if you're using Jacob's port) to make sure that you
have the latest copy and have installed it correctly. It those these
are true, then stop using lcc.
 
K

Keith Thompson

new to c said:
I write this code cos.c

#include <math.h>
#include <stdio.h>

int main(void)
{
double c;
c = cos(0);
printf("cos(0): %f\n", c);
return 0;
}

I compile normal and it work.

I compile with -pedantic and it not work.

Is -pedantic bad flag?

Is code bug?

I use lcc -pedantic cos.c and he warn
[snip]

This is not a C language issue. You have a problem with lcc, or with
your installation of it.

The lcc compiler has its own newsgroup, comp.compilers.lcc. You
should post your question there. Please specify whether you're using
lcc or lcc-win (the latter is also known as lcc-win32), and which
version.
 
B

Bartc

new to c said:
Hi!

I write this code cos.c

#include <math.h>
#include <stdio.h>

int main(void)
{
double c;
c = cos(0);
printf("cos(0): %f\n", c);
return 0;
}

I compile normal and it work.

I compile with -pedantic and it not work.

Is -pedantic bad flag?

Is code bug?

I use lcc -pedantic cos.c and he warn

Error cos.c: c:\lcc\include\math.h: 36 Syntax error; missing semicolon
before `_cosl'

Notice all the errors are for the header file?

If you look at the math.h file, it uses special extensions like // comments
and _stdcall.

I would say there is a bug in this compiler because perhaps the -pedantic
flag should be ignored when compiling it's own system headers (when you port
your code elsewhere, you will use a different set of headers).

Either forget -pedantic when using math.h (or whatever else), or ignore the
warnings for this header, or switch compilers.
 
V

vippstar

Notice all the errors are for the header file?

If you look at the math.h file, it uses special extensions like // comments
and _stdcall.
// comments are not an extension, they are standarized with ISO C99.
I would say there is a bug in this compiler because perhaps the -pedantic
flag should be ignored when compiling it's own system headers (when you port
your code elsewhere, you will use a different set of headers).

Either forget -pedantic when using math.h (or whatever else), or ignore the
warnings for this header, or switch compilers.
I don't think they are warnings, warnings don't interrupt the
compilation.
I think Mr Navia should just fix the bug, because it *is* a bug, well,
depending on what -pedantic says it does, but if it just provides more
warnings/errors for standard C mode, then it's certainly a bug.
 
K

Keith Thompson

Richard Heathfield said:
Malcolm McLean said:

Where do you draw the line, then? Because this isn't the first lcc-win32
bug, by any means, that has been reported in comp.lang.c in recent months.
[...]

I've seen no evidence that the original post was referring to
lcc-win32. The poster referred to "lcc".
 
B

Bartc

Richard Heathfield said:
Keith Thompson said:

True enough, and a fair point, although the reaction from Mr Navia
suggests
that this bug exists in lcc-win32 too. Generally, however, the point
remains - that it isn't just one bug that is the issue here. Nor is it
even many bugs. The real issue is one of how we respond to bug reports.

My experience is that lcc-win problems are dealt with promptly and helpfully
in comp.compilers.lcc.

Some issues I can work around by spending a few minutes investigating the
cause (rather than immediately post, inappropriately, to comp.lang.c), and
then I may possibly submit an observation to comp.compilers.lcc.

So I think it might be the attitude in this group that can produce the sort
of response you've seen. To quote from your own post in this thread:
Then you have a broken compiler. I suggest you switch to something that
works, such as gcc.
But then, gcc (when invoked with appropriate flags, of
which -pedantic is one) is a C compiler, which is always a good thing to
start with if you want to compile C programs.

I think /I/ would start to get angry too, at dismissing a considerable body
of work just like that.
 
K

Kenny McCormack

To write MiniBasic I dug out my old BBC Basic handbook, junked Procs (add
too much complexity), gosub (useless) and read / data (too confusing), and
added array intialisers, which do much the same thing as read / data more
intutively.
I also rationalised a bit so that every function that returns a string has a
dollar sign appended to it, all variables are double precision, arrays can
be redimensioned, and computed goto is allowed - that last was maybe a
mistake.

The result was something that doesn't conform to any standard, but is pretty
clearly a BASIC interpreter.

No.

Not in the terminology (read: warped world view) of the CLC regs.
You should certainly know this by now.
 
K

Keith Thompson

Malcolm McLean said:
To write MiniBasic I dug out my old BBC Basic handbook, junked Procs
(add too much complexity), gosub (useless) and read / data (too
confusing), and added array intialisers, which do much the same thing
as read / data more intutively.
I also rationalised a bit so that every function that returns a string
has a dollar sign appended to it, all variables are double precision,
arrays can be redimensioned, and computed goto is allowed - that last
was maybe a mistake.

The result was something that doesn't conform to any standard, but is
pretty clearly a BASIC interpreter.

And this has what exactly to do with C, the topic of this newsgroup?

I'm sure you're proud of your MiniBasic, but why advertise it here?
 
K

Kenny McCormack

The result was something that doesn't conform to any standard, but is
pretty clearly a BASIC interpreter.

And this has what exactly to do with C, the topic of this newsgroup?

I'm sure you're proud of your MiniBasic, but why advertise it here?[/QUOTE]

I'm not surprised that someone with your limited mental facility doesn't
get it. But be assured, Malcolm's post was entirely well placed in the
flow of this thread.
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top