// comments

S

santosh

Ben said:
I considered that meaning, but since santosh was replying to a message
that stated that -ansi89 treats restrict as a keyword, that did not
seem like a reasonable interpretation.

Yes. The lcc-win manual that I have indicates that the -ansi switch
makes the compiler conform to C99. Your post up-thread which seemed to
indicate that lcc-win accepted several C99 constructs when
under -ansi89 suggested to me that jacob might have simply made -ansi89
a synonym for -ansi with a few more check (presumably whatever his
paying customer asked for) added in. This would mean that -ansi89 isn't
really suitable for making lcc-win conform to C90. This is also borne
out by the fact that the -ansi89 switch isn't listed in the lcc-win
manual I have here.
 
H

Harald van Dijk

Ben said:
I considered that meaning, but since santosh was replying to a message
that stated that -ansi89 treats restrict as a keyword, that did not
seem like a reasonable interpretation.

Yes. The lcc-win manual that I have indicates that the -ansi switch
makes the compiler conform to C99. [...]

Interesting. I still happened to have the Linux version of lcc installed,
and it doesn't support any -ansi option, but does support the -ansi89
option.

Warning 0 Ignoring unknown option '-ansi'

Because of that, I didn't consider the possibility of an lcc option -ansi
since added.
 
S

santosh

Harald said:
Ben said:
On Sun, 27 Apr 2008 13:36:20 +0100, Ben Bacarisse wrote:
Maybe jacob implemented -ansi89 switch as a synonym for -ansi?

Sorry, I don't follow.

With GCC, -ansi means that valid C90 programs will be accepted, but
invalid C90 programs, complete with syntax errors and/or constraint
violations, will not necessarily be rejected. It's possible that
jacob navia made -ansi89 behave the same way in lcc-win32.

I considered that meaning, but since santosh was replying to a
message that stated that -ansi89 treats restrict as a keyword, that
did not seem like a reasonable interpretation.

Yes. The lcc-win manual that I have indicates that the -ansi switch
makes the compiler conform to C99. [...]

Interesting. I still happened to have the Linux version of lcc
installed, and it doesn't support any -ansi option, but does support
the -ansi89 option.

Warning 0 Ignoring unknown option '-ansi'

Because of that, I didn't consider the possibility of an lcc option
-ansi since added.

I too still have the aborted Linux version installed, but the
information above was taken from the installation lcc-win32 under WINE.
 
B

Ben Bacarisse

Bartc said:
I think it's more of a problem of the design of the // comment convention,
in that this ambiguity can occur.

That is true. The supposition made by the utility is that the above
program needs fixing. The problem I cite is really only a problem for
a "C90 compiler with // comments". Such a compiler needs to choose
between the interpretations.
 
B

Ben Bacarisse

Harald van Dijk said:
Ben said:
On Sun, 27 Apr 2008 13:36:20 +0100, Ben Bacarisse wrote:
Maybe jacob implemented -ansi89 switch as a synonym for -ansi?

Sorry, I don't follow.

With GCC, -ansi means that valid C90 programs will be accepted, but
invalid C90 programs, complete with syntax errors and/or constraint
violations, will not necessarily be rejected. It's possible that jacob
navia made -ansi89 behave the same way in lcc-win32.

I considered that meaning, but since santosh was replying to a message
that stated that -ansi89 treats restrict as a keyword, that did not
seem like a reasonable interpretation.

Yes. The lcc-win manual that I have indicates that the -ansi switch
makes the compiler conform to C99. [...]

Interesting. I still happened to have the Linux version of lcc installed,
and it doesn't support any -ansi option, but does support the -ansi89
option.

Warning 0 Ignoring unknown option '-ansi'

Because of that, I didn't consider the possibility of an lcc option -ansi
since added.

It hasn't been added. I think santosh is referring to the -ansic flag.
 
B

Ben Bacarisse

santosh said:
Yes. The lcc-win manual that I have indicates that the -ansi switch

You mean -ansic yes?
makes the compiler conform to C99. Your post up-thread which seemed to
indicate that lcc-win accepted several C99 constructs when
under -ansi89 suggested to me that jacob might have simply made -ansi89
a synonym for -ansi with a few more check (presumably whatever his
paying customer asked for) added in.

No. It does, for example stop inline being a keyword and stops
declarations being mixed with statements.
This would mean that -ansi89 isn't
really suitable for making lcc-win conform to C90. This is also borne
out by the fact that the -ansi89 switch isn't listed in the lcc-win
manual I have here.

Jacob seems to be saying that it is a custom flag for one particular
purpose. As such, it seems that lcc-win32 has no C90/C89 conforming
mode and the specific tests made when -ansi89 are given were selected
by a customer and don't have much to do with the standard.
 
S

santosh

Ben said:
[ ... ]
You mean -ansic yes?

Sorry yes. Time for another cup of tea. :)
No. It does, for example stop inline being a keyword and stops
declarations being mixed with statements.

Okay, but if it is intended to be a generally usable option then jacob
needs to do more work.
Jacob seems to be saying that it is a custom flag for one particular
purpose. As such, it seems that lcc-win32 has no C90/C89 conforming
mode and the specific tests made when -ansi89 are given were selected
by a customer and don't have much to do with the standard.

This is my impression too. Also if (as it seems to me) jacob has not
documented the -ansi89 switch anywhere, and it was meant only for a
specific customer, I wonder how the OP stumbled on it. I guess he just
happened to use -ansi89 and saw that it was accepted.

It would be helpful if jacob could clarify things further, perhaps in
comp.compilers.lcc.
 
J

jacob navia

santosh said:
Ben said:
[ ... ]
You mean -ansic yes?

Sorry yes. Time for another cup of tea. :)
No. It does, for example stop inline being a keyword and stops
declarations being mixed with statements.

Okay, but if it is intended to be a generally usable option then jacob
needs to do more work.
Jacob seems to be saying that it is a custom flag for one particular
purpose. As such, it seems that lcc-win32 has no C90/C89 conforming
mode and the specific tests made when -ansi89 are given were selected
by a customer and don't have much to do with the standard.

This is my impression too. Also if (as it seems to me) jacob has not
documented the -ansi89 switch anywhere, and it was meant only for a
specific customer, I wonder how the OP stumbled on it. I guess he just
happened to use -ansi89 and saw that it was accepted.

It would be helpful if jacob could clarify things further, perhaps in
comp.compilers.lcc.

Really, you think it would be fun to work for making my compiler system
refuse // comments?

If Mr "teapot" pays me 1 day consulting I would do it, but just for the
fun of the regulars here?

I added the ansi89 flag for a specific customer. I thought some people
would be happy to see the C99 dependencies in their code. OK. But I
haven't a team of people like gcc, so it is just impossible to do now.

Of course if the regulars PAY for it it *could* be done.

:)
 
F

Flash Gordon

jacob navia wrote, On 27/04/08 16:10:
Really, you think it would be fun to work for making my compiler system
refuse // comments?

Santosh says the switch is undocumented. If this is the case then it
doesn't matter what it does and anyone who "stumbles across it" and uses
it deserves anything that get.
If Mr "teapot" pays me 1 day consulting I would do it, but just for the
fun of the regulars here?

I added the ansi89 flag for a specific customer.

If it does what that customer wants (and that is between you and the
customer, not us) then fine.
I thought some people
would be happy to see the C99 dependencies in their code. OK.

Well, as has been pointed out it at most shows *some* C99 dependencies,
not all.
But I
haven't a team of people like gcc, so it is just impossible to do now.

Of course if the regulars PAY for it it *could* be done.

:)

As this is unlikely just leave the switch undocumented or documented as
not being fully conforming. Then there is nothing for anyone here to
complain about with regards to that switch.
 
H

Harald van Dijk

ANY conforming C90 compiler doesn't understand // comments. Otherwise it
isn't a conforming C90 compiler.

A conforming C90 compiler is allowed to understand // comments in those
situations where they would otherwise be syntax errors.

But I think ymuntyan's question is whether any conforming C90 compiler
has no other mode (whether conforming or nonconforming) where // comments
are accepted.
 
K

Keith Thompson

Harald van Dijk said:
A conforming C90 compiler is allowed to understand // comments in those
situations where they would otherwise be syntax errors.

But it must still diagnose those syntax errors.

[...]
 
H

Harald van Dijk

Did you mean situations where they would otherwise not be syntax errors?

No, in those situations, it is specifically not allowed to understand //
comments.

A conforming C90 compiler must make

int main(void) {
return 1 //* hello, world! */
+ 2;
}

return 0. A conforming C99 compiler must make it return 3 (whatever that
means), and a nonconforming C90-based compiler that accepts // comments
as an extension typically does the same.

A conforming C90 compiler may accept

int main(void) {
return 0; // hello, world!
}

(provided it diagnoses the syntax error, as pointed out by Keith
Thompson), and this is what I was referring to.
 
S

santosh

Harald said:
No, in those situations, it is specifically not allowed to understand
// comments.

A conforming C90 compiler must make

int main(void) {
return 1 //* hello, world! */
+ 2;
}

return 0. A conforming C99 compiler must make it return 3 (whatever
that means), and a nonconforming C90-based compiler that accepts //
comments as an extension typically does the same.

A conforming C90 compiler may accept

int main(void) {
return 0; // hello, world!
}

(provided it diagnoses the syntax error, as pointed out by Keith
Thompson), and this is what I was referring to.

okay, thanks for the clarification.
 
R

robertwessel2

-ansi89 was implemented to the wishes of a paying customer. They wanted
a compiler to that standard, and I implemented it for them. The usage of
that flag is to disable most C99 stuff.

Note that many compilers at the C89 level accept // comments, for instance
Microsoft compilers


Actually with "-Za -W4" MSVC2005 emits:

"test49.c(7) : warning C4001: nonstandard extension 'single line
comment' was used"
 
W

William Hughes

Actually I was wrong, I have no idea if there was a C
compiler which didn't understand // comments. By the time
when a compiler got to C90 conformance (N years after 1990),
// comments were probably already there. What conforming C90
compiler doesn't understand // comments? Just curious.

Yevgen



Well, strictly speaking no conforming C90 compiler can "understand"
// comments (see elsethread for more details). However, if your
question
is "is there a conforming compiler which cannot be invoked in a mode
in
which it understands // comments" then I do not know of one, and
certainly
the most popular compilers do have a mode in which // is understood.
What they do not have is a mode in which the only extension understood
is //
comments. So if you use // comments you can no longer use these
compilers
in a conforming mode.
- William Hughes
 
J

Joachim Schmitz

William Hughes wrote:
Well, strictly speaking no conforming C90 compiler can "understand"
// comments (see elsethread for more details). However, if your
question
is "is there a conforming compiler which cannot be invoked in a mode
in
which it understands // comments" then I do not know of one, and
certainly
the most popular compilers do have a mode in which // is understood.
What they do not have is a mode in which the only extension understood
is //
comments.
I know one such compiler (hmm, actually two), it
uses -Wallow_cplusplus_comments for that and only for that.
So if you use // comments you can no longer use these
compilers
in a conforming mode.
Not quite so...

Bye, Jojo
 

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

Similar Threads

How to remove // comments 100
Command Line Arguments 0
A simple parser 121
Text processing 29
Working with files 1
Serial port 5
Taking a stab at getline 40
hexump.c 79

Members online

No members online now.

Forum statistics

Threads
474,091
Messages
2,570,605
Members
47,225
Latest member
DarrinWhit

Latest Threads

Top