Hello all,
I remember that I saw a piece of code a few years ago, it was using a
combination of both /* */ and // such that you could determine the
compile type of the source code. I don't remember exactly what was
happening, but I assume it was something like if the source code was
being compiled by a c compiler the value of a variable became 1 and if
it was compiled with c++ compiler the value became 0. Do you know how
can I find that ?
Any ideas ?
Thanks in advance, 28 1960
"Hapary" <ha****@gmail.comwrote in message
news:11*********************@y80g2000hsf.googlegro ups.com...
Hello all,
I remember that I saw a piece of code a few years ago, it was using a
combination of both /* */ and // such that you could determine the
compile type of the source code. I don't remember exactly what was
happening, but I assume it was something like if the source code was
being compiled by a c compiler the value of a variable became 1 and if
it was compiled with c++ compiler the value became 0. Do you know how
can I find that ?
/* */ is a legal C++ comment whilst // is not a legal sequence in C. C++
comments comment each other out. I can't think of a way to achieve this.
The standard, acceptable way is to use the #ifdef __cplusplus construct
provided for the purpose.
--
Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm
Malcolm McLean wrote:
>
"Hapary" <ha****@gmail.comwrote in message
news:11*********************@y80g2000hsf.googlegro ups.com...
>Hello all,
I remember that I saw a piece of code a few years ago, it was using a combination of both /* */ and // such that you could determine the compile type of the source code. I don't remember exactly what was happening, but I assume it was something like if the source code was being compiled by a c compiler the value of a variable became 1 and if it was compiled with c++ compiler the value became 0. Do you know how can I find that ?
/* */ is a legal C++ comment whilst // is not a legal sequence in C.
It is in C99.
--
Ian Collins.
"Malcolm McLean" <re*******@btinternet.comwrites:
"Hapary" <ha****@gmail.comwrote in message
news:11*********************@y80g2000hsf.googlegro ups.com...
>Hello all,
I remember that I saw a piece of code a few years ago, it was using a combination of both /* */ and // such that you could determine the compile type of the source code. I don't remember exactly what was happening, but I assume it was something like if the source code was being compiled by a c compiler the value of a variable became 1 and if it was compiled with c++ compiler the value became 0. Do you know how can I find that ?
/* */ is a legal C++ comment whilst // is not a legal sequence in
C. C++ comments comment each other out. I can't think of a way to
achieve this.
The standard, acceptable way is to use the #ifdef __cplusplus
construct provided for the purpose.
// introduces a comment in C99.
In C90, // could be a division operator immediately followed by the
first character of a /* ... */ comment.
For example:
#include <stdio.h>
int main(void)
{
char *messages[] = {
"// comments are not accepted",
"// comments are accepted"
};
int i = 2 //**/ 2
- 1;
puts(messages[i]);
return 0;
}
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
"Malcolm McLean" <re*******@btinternet.comwrites:
>"Hapary" <ha****@gmail.comwrote in message news:11*********************@y80g2000hsf.googlegr oups.com...
>>Hello all,
I remember that I saw a piece of code a few years ago, it was using a combination of both /* */ and // such that you could determine the compile type of the source code. I don't remember exactly what was happening, but I assume it was something like if the source code was being compiled by a c compiler the value of a variable became 1 and if it was compiled with c++ compiler the value became 0. Do you know how can I find that ?
/* */ is a legal C++ comment whilst // is not a legal sequence in C. C++ comments comment each other out. I can't think of a way to achieve this. The standard, acceptable way is to use the #ifdef __cplusplus construct provided for the purpose.
// introduces a comment in C99.
In C90, // could be a division operator immediately followed by the
first character of a /* ... */ comment.
Aha, we can do it
x = 2 //* C comment */ 2;
;
Now we've got x = 2 in C++ and x = 1 in C.
--
Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm
Ian Collins said:
Malcolm McLean wrote:
>> "Hapary" <ha****@gmail.comwrote in message news:11*********************@y80g2000hsf.googlegr oups.com...
>>Hello all,
I remember that I saw a piece of code a few years ago, it was using a combination of both /* */ and // such that you could determine the compile type of the source code. I don't remember exactly what was happening, but I assume it was something like if the source code was being compiled by a c compiler the value of a variable became 1 and if it was compiled with c++ compiler the value became 0. Do you know how can I find that ?
/* */ is a legal C++ comment whilst // is not a legal sequence in C.
It is in C99.
You can make it a legal sequence in C90, too, if you try hard enough:
a = b//*how silly*/c
;
is legal in both C90 and C99. IIRC C99 disambiguates the code by dealing
with the first legal comment syntax it encounters, so these two lines
have different meanings in C90 and C99.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
Malcolm McLean wrote:
>
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
>"Malcolm McLean" <re*******@btinternet.comwrites:
>>"Hapary" <ha****@gmail.comwrote in message news:11*********************@y80g2000hsf.googleg roups.com...
Hello all,
I remember that I saw a piece of code a few years ago, it was using a combination of both /* */ and // such that you could determine the compile type of the source code. I don't remember exactly what was happening, but I assume it was something like if the source code was being compiled by a c compiler the value of a variable became 1 and if it was compiled with c++ compiler the value became 0. Do you know how can I find that ?
/* */ is a legal C++ comment whilst // is not a legal sequence in C. C++ comments comment each other out. I can't think of a way to achieve this. The standard, acceptable way is to use the #ifdef __cplusplus construct provided for the purpose.
// introduces a comment in C99.
In C90, // could be a division operator immediately followed by the first character of a /* ... */ comment.
Aha, we can do it
x = 2 //* C comment */ 2;
;
Now we've got x = 2 in C++ and x = 1 in C.
No, you get a syntax error in C99 and C++ (the ; is part of the comment).
--
Ian Collins.
Ian Collins <ia******@hotmail.comwrote:
Malcolm McLean wrote:
Aha, we can do it
x = 2 //* C comment */ 2;
;
Now we've got x = 2 in C++ and x = 1 in C.
No, you get a syntax error in C99 and C++ (the ; is part of the comment).
There are two semicolons. In C90, it's two statements; in C99, one.
Richard
Richard Bos wrote:
Ian Collins <ia******@hotmail.comwrote:
>>Malcolm McLean wrote:
>>>Aha, we can do it
x = 2 //* C comment */ 2; ;
Now we've got x = 2 in C++ and x = 1 in C.
No, you get a syntax error in C99 and C++ (the ; is part of the comment).
There are two semicolons. In C90, it's two statements; in C99, one.
Oops, I missed that.
--
Ian Collins.
On Apr 10, 11:32 am, "Malcolm McLean" <regniz...@btinternet.com>
wrote:
"Keith Thompson" <k...@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
"Malcolm McLean" <regniz...@btinternet.comwrites:
"Hapary" <hap...@gmail.comwrote in message news:11*********************@y80g2000hsf.googlegr oups.com... Hello all,
>I remember that I saw a piece of code a few years ago, it was using a combination of both /* */ and // such that you could determine the compile type of the source code. I don't remember exactly what was happening, but I assume it was something like if the source code was being compiled by a c compiler the value of a variable became 1 and if it was compiled with c++ compiler the value became 0. Do you know how can I find that ?
/* */ is a legal C++ comment whilst // is not a legal sequence in
C. C++ comments comment each other out. I can't think of a way to
achieve this.
The standard, acceptable way is to use the #ifdef __cplusplus
construct provided for the purpose.
// introduces a comment in C99.
In C90, // could be a division operator immediately followed by the
first character of a /* ... */ comment.
Aha, we can do it
x = 2 //* C comment */ 2;
;
Now we've got x = 2 in C++ and x = 1 in C.
--
Free games and programming goodies.http://www.personal.leeds.ac.uk/~bgy1mm
just remove the first semicolon
x = 2 //* C comment */ 2
;
Now it should work on both
"Malcolm McLean" <re*******@btinternet.comwrites:
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
>"Malcolm McLean" <re*******@btinternet.comwrites:
>>"Hapary" <ha****@gmail.comwrote in message news:11*********************@y80g2000hsf.googleg roups.com... Hello all,
I remember that I saw a piece of code a few years ago, it was using a combination of both /* */ and // such that you could determine the compile type of the source code. I don't remember exactly what was happening, but I assume it was something like if the source code was being compiled by a c compiler the value of a variable became 1 and if it was compiled with c++ compiler the value became 0. Do you know how can I find that ?
/* */ is a legal C++ comment whilst // is not a legal sequence in C. C++ comments comment each other out. I can't think of a way to achieve this. The standard, acceptable way is to use the #ifdef __cplusplus construct provided for the purpose.
// introduces a comment in C99.
In C90, // could be a division operator immediately followed by the first character of a /* ... */ comment.
Aha, we can do it
x = 2 //* C comment */ 2;
;
Now we've got x = 2 in C++ and x = 1 in C.
Congratulations. Was there some reason you snipped my sample code and
added your own? Or did you just stop reading at that point?
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
"Malcolm McLean" <re*******@btinternet.comwrites:
>"Keith Thompson" <ks***@mib.orgwrote in message news:ln************@nuthaus.mib.org...
>>"Malcolm McLean" <re*******@btinternet.comwrites: "Hapary" <ha****@gmail.comwrote in message news:11*********************@y80g2000hsf.google groups.com... Hello all, > I remember that I saw a piece of code a few years ago, it was using a combination of both /* */ and // such that you could determine the compile type of the source code. I don't remember exactly what was happening, but I assume it was something like if the source code was being compiled by a c compiler the value of a variable became 1 and if it was compiled with c++ compiler the value became 0. Do you know how can I find that ? > /* */ is a legal C++ comment whilst // is not a legal sequence in C. C++ comments comment each other out. I can't think of a way to achieve this. The standard, acceptable way is to use the #ifdef __cplusplus construct provided for the purpose.
// introduces a comment in C99.
In C90, // could be a division operator immediately followed by the first character of a /* ... */ comment.
Aha, we can do it
x = 2 //* C comment */ 2; ;
Now we've got x = 2 in C++ and x = 1 in C.
Congratulations. Was there some reason you snipped my sample code and
added your own? Or did you just stop reading at that point?
Stopped reading.
"Malcolm McLean" <re*******@btinternet.comwrites:
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
[...]
>Congratulations. Was there some reason you snipped my sample code and added your own? Or did you just stop reading at that point?
Stopped reading.
Ok. In the future, please do me (and the rest of your readers) the
courtesy of reading the whole article before you post a followup.
You'll look less foolish.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
"Malcolm McLean" <re*******@btinternet.comwrites:
>"Keith Thompson" <ks***@mib.orgwrote in message news:ln************@nuthaus.mib.org...
[...]
>>Congratulations. Was there some reason you snipped my sample code and added your own? Or did you just stop reading at that point?
Stopped reading.
Ok. In the future, please do me (and the rest of your readers) the
courtesy of reading the whole article before you post a followup.
You'll look less foolish.
I tend to assume that code will reflect the English. In your case you said
that a double slash was a legal C construct if the second slash was part of
a comment. So I assumed that the code was designed to illustrate that. That
was my mistake, but the general rule is that people read code if they intend
to run it or alter it, comments if they intend to understand what it does.
On Tue, 10 Apr 2007 23:50:49 +0100, "Malcolm McLean"
<re*******@btinternet.comwrote:
>, but the general rule is that people read code if they intend to run it or alter it, comments if they intend to understand what it does.
Not me. As a maintenance programmer, I read comments as a last resort,
and even then I don't believe them. They're only a possible clue to
the original programmer's state of mind at the time.
--
Al Balmer
Sun City, AZ
"Al Balmer" <al******@att.netwrote in message
news:go********************************@4ax.com...
On Tue, 10 Apr 2007 23:50:49 +0100, "Malcolm McLean"
<re*******@btinternet.comwrote:
>>, but the general rule is that people read code if they intend to run it or alter it, comments if they intend to understand what it does.
Not me. As a maintenance programmer, I read comments as a last resort,
and even then I don't believe them. They're only a possible clue to
the original programmer's state of mind at the time.
That's running or altering code.
In article <go********************************@4ax.com>,
Al Balmer <al******@att.netwrote:
>On Tue, 10 Apr 2007 23:50:49 +0100, "Malcolm McLean" <re*******@btinternet.comwrote:
>>, but the general rule is that people read code if they intend to run it or alter it, comments if they intend to understand what it does.
Not me. As a maintenance programmer, I read comments as a last resort, and even then I don't believe them. They're only a possible clue to the original programmer's state of mind at the time.
I can do worse than that; sometimes they're only a clue to how completely
clueless somebody who looked at the code later was.
A sample from the code I work with at my day job:
--------
//initialize to the min_threshold (maybe max would be better to
// avoid huge amounts of detections?)
/*Max threshold is only a good idea if you never want to adapt
below that, which kind of defeats the whole purpose of what
we're doing here. --DV
*/
for(i=0;i<N;i++)
values[i]=min_threshold;
--------
The code was written by me; the // comment was written by another
programmer, and the /*...*/ comment was just added by me while making
a change to the code.
And no, he wasn't commenting it because he had to understand it to make
a change; it's entirely internal to a module in which all of the live
code past the external interface is mine.
dave
--
Dave Vandervies dj******@csclub.uwaterloo.ca
I am not too upset about the missing smiley, however, because I know you
are from one of those Scandinavian countries with the funny keyboards ...
--Jack Klein in comp.lang.c
Malcolm McLean wrote, On 10/04/07 23:50:
>
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
>"Malcolm McLean" <re*******@btinternet.comwrites:
>>"Keith Thompson" <ks***@mib.orgwrote in message news:ln************@nuthaus.mib.org...
[...]
>>>Congratulations. Was there some reason you snipped my sample code and added your own? Or did you just stop reading at that point?
Stopped reading.
Ok. In the future, please do me (and the rest of your readers) the courtesy of reading the whole article before you post a followup. You'll look less foolish.
I tend to assume that code will reflect the English. In your case you
said that a double slash was a legal C construct if the second slash was
part of a comment. So I assumed that the code was designed to illustrate
that. That was my mistake, but the general rule is that people read code
if they intend to run it or alter it, comments if they intend to
understand what it does.
That may be your rule. Personally I find that on language groups it is
best to read the code people provide so I know what they are talking about.
--
Flash Gordon
On Wed, 11 Apr 2007 00:23:36 +0100, "Malcolm McLean"
<re*******@btinternet.comwrote:
> "Al Balmer" <al******@att.netwrote in message news:go********************************@4ax.com.. .
>On Tue, 10 Apr 2007 23:50:49 +0100, "Malcolm McLean" <re*******@btinternet.comwrote:
>>>, but the general rule is that people read code if they intend to run it or alter it, comments if they intend to understand what it does.
Not me. As a maintenance programmer, I read comments as a last resort, and even then I don't believe them. They're only a possible clue to the original programmer's state of mind at the time.
That's running or altering code.
It's both. I don't alter code without understanding what it does.
--
Al Balmer
Sun City, AZ
"Malcolm McLean" <re*******@btinternet.comwrites:
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
>"Malcolm McLean" <re*******@btinternet.comwrites:
>>"Keith Thompson" <ks***@mib.orgwrote in message news:ln************@nuthaus.mib.org...
[...]
>>>Congratulations. Was there some reason you snipped my sample code and added your own? Or did you just stop reading at that point?
Stopped reading.
Ok. In the future, please do me (and the rest of your readers) the courtesy of reading the whole article before you post a followup. You'll look less foolish.
I tend to assume that code will reflect the English. In your case you
said that a double slash was a legal C construct if the second slash
was part of a comment.
Not quite. What I said was that *in C90* a double slash could be a
division operator immediately followed by the first character of a /*
.... */ comment. In C99 (which is also C), a double slash can
introduce a comment.
So I assumed that the code was designed to
illustrate that.
It was, after allowing for the C99 correction above.
That was my mistake, but the general rule is that
people read code if they intend to run it or alter it, comments if
they intend to understand what it does.
Here's what I wrote upthread, excluding quoted text. I encourage you
to read it all this time.
| // introduces a comment in C99.
|
| In C90, // could be a division operator immediately followed by the
| first character of a /* ... */ comment.
|
| For example:
|
| #include <stdio.h>
| int main(void)
| {
| char *messages[] = {
| "// comments are not accepted",
| "// comments are accepted"
| };
| int i = 2 //**/ 2
| - 1;
| puts(messages[i]);
| return 0;
| }
In your followup, you snipped everything starting with "For example:",
and wrote this:
| Aha, we can do it
|
| x = 2 //* C comment */ 2;
| ;
|
| Now we've got x = 2 in C++ and x = 1 in C.
So you wrote a code snippet that illustrates exactly the same point
that mine did (except that you incorrectly ignored the fact that C99
supports // comments). You also gave the false impression that I had
merely made a general comment and that you had jumped in to provide
the specific example that I had failed to provide.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
"Malcolm McLean" <re*******@btinternet.comwrites:
>"Keith Thompson" <ks***@mib.orgwrote in message news:ln************@nuthaus.mib.org...
>>"Malcolm McLean" <re*******@btinternet.comwrites: "Keith Thompson" <ks***@mib.orgwrote in message news:ln************@nuthaus.mib.org... [...] Congratulations. Was there some reason you snipped my sample code and added your own? Or did you just stop reading at that point? > Stopped reading.
Ok. In the future, please do me (and the rest of your readers) the courtesy of reading the whole article before you post a followup. You'll look less foolish.
I tend to assume that code will reflect the English. In your case you said that a double slash was a legal C construct if the second slash was part of a comment.
Not quite. What I said was that *in C90* a double slash could be a
division operator immediately followed by the first character of a /*
... */ comment. In C99 (which is also C), a double slash can
introduce a comment.
> So I assumed that the code was designed to illustrate that.
It was, after allowing for the C99 correction above.
> That was my mistake, but the general rule is that people read code if they intend to run it or alter it, comments if they intend to understand what it does.
Here's what I wrote upthread, excluding quoted text. I encourage you
to read it all this time.
| // introduces a comment in C99.
|
| In C90, // could be a division operator immediately followed by the
| first character of a /* ... */ comment.
|
| For example:
|
| #include <stdio.h>
| int main(void)
| {
| char *messages[] = {
| "// comments are not accepted",
| "// comments are accepted"
| };
| int i = 2 //**/ 2
| - 1;
| puts(messages[i]);
| return 0;
| }
In your followup, you snipped everything starting with "For example:",
and wrote this:
| Aha, we can do it
|
| x = 2 //* C comment */ 2;
| ;
|
| Now we've got x = 2 in C++ and x = 1 in C.
So you wrote a code snippet that illustrates exactly the same point
that mine did (except that you incorrectly ignored the fact that C99
supports // comments). You also gave the false impression that I had
merely made a general comment and that you had jumped in to provide
the specific example that I had failed to provide.
Yes, I am sorry.
On the other hand the thread was about writing code that compiled under two
languages. You seem to be taking your moment of triumph far too seriously.
--
Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm
In article <go********************************@4ax.com>, Al Balmer
<al******@att.netwrites
>On Tue, 10 Apr 2007 23:50:49 +0100, "Malcolm McLean" <re*******@btinternet.comwrote:
>>, but the general rule is that people read code if they intend to run it or alter it, comments if they intend to understand what it does.
Not me. As a maintenance programmer, I read comments as a last resort, and even then I don't believe them. They're only a possible clue to the original programmer's state of mind at the time.
.... at the time he wrote the comment which may or may not be the same
time he (or some one else) wrote the code in the same vicinity as the
comment.
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
In article <c5********************************@4ax.com>, Al Balmer
<al******@att.netwrites
>On Wed, 11 Apr 2007 00:23:36 +0100, "Malcolm McLean" <re*******@btinternet.comwrote:
>> "Al Balmer" <al******@att.netwrote in message news:go********************************@4ax.com. ..
>>On Tue, 10 Apr 2007 23:50:49 +0100, "Malcolm McLean" <re*******@btinternet.comwrote:
, but the general rule is that people read code if they intend to run it or alter it, comments if they intend to understand what it does.
Not me. As a maintenance programmer, I read comments as a last resort, and even then I don't believe them. They're only a possible clue to the original programmer's state of mind at the time.
That's running or altering code.
It's both. I don't alter code without understanding what it does.
Without thinking you know what it does..... :-)
I have seen code that produced the answers the programmer expected but
did not work in the way he thought it did. It was Just a happy
coincidence it gave the correct answers for the range of inputs. When
the input range got changed it became unreliable.
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Dear All,
I never expected to get the answer to my question here, and I just
wanted to thank all of you, and sorry if I caused to make a flame
between the group members (never had the intention though).
Despite the fact that the code doesn't compile as it is expected in
VC6, but I guess that's as far as we can go. I wanted to have a sample
and I got it (VC6 accepts the // as a comment even in a .c file in its
default configuration, maybe there is a special switch for preventing
it to do that, but I don't know).
Thanks again,
Hapary wrote:
>
I never expected to get the answer to my question here, and I just
wanted to thank all of you, and sorry if I caused to make a flame
between the group members (never had the intention though).
Don't worry about the flaming. It is the normal result of almost
any enquiry.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
--
Posted via a free Usenet account from http://www.teranews.com
Hapary said:
(VC6 accepts the // as a comment even in a .c file in its
default configuration, maybe there is a special switch for preventing
it to do that, but I don't know).
If you want the compiler to use the rules of C when translating the
code, ensure that the filename ends in .c (as you appear to have done),
and disable Microsoft extensions. This can be done in the options
menus, or (IIRC) by using the /Za flag.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
On Mon, 16 Apr 2007 05:21:11 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>Hapary said:
>(VC6 accepts the // as a comment even in a .c file in its default configuration, maybe there is a special switch for preventing it to do that, but I don't know).
If you want the compiler to use the rules of C when translating the code, ensure that the filename ends in .c (as you appear to have done), and disable Microsoft extensions. This can be done in the options menus, or (IIRC) by using the /Za flag.
And if your strictly conforming C90 compiler supports it, enable the
option that warns about identifiers that are intended to denote the
same entity *and* differ in a character beyond the minimal significant
characters (six) (1). For example, the following function names with
external linkage are not strictly C90 conforming:
DequeAddAtFront
DequeAddAtBack
DequeRemoveFromFront
DequeRemoveFromBack
DequeGetDataFromFront
DequeGetDataFromBack
Of course, the number of minimal significant characters was increased
for C99 (and recommended for C90--see below), such that all of the
above identifiers are strictly conforming, but we all know C99 is not
the de facto standard discussed in this newsgroup, and suggestive text
is not normative, so it's a moot point (2).
Best regards
--
jay
(2) The C90 standard recommended that implementations support an
increased number of minimal significant characters in identifier names
beyond the strict length of six (which most if not all implementations
did support--and most if not all C programmers took advantage of,
whether cognizant of the small print or not). But, nevertheless,
identifiers that violate (1) result in, strictly speaking, undefined
behavior in C90. And that, according to some, could result in starting
WWIII. How ironic that would be if C Unleashed was somehow responsible
for leading to the spark that started WWIII. If so, I can live with
that.
FWIW, I have no problem whatsoever witht the above function name
identifiers. In fact, I'd have problems if they were named something
obscure like the following in order to play silly games and be
strictly conforming:
DqAdd1AtFront
DqAdd2AtBack
DqRem1FromFront
DqRem2FromBack
DqGet1DataFromFront
DqGet2DataFromBack
Around here, "Dq" stands for "Dairy Queen" :)
jaysome said:
<snip>
And if your strictly conforming C90 compiler supports it, enable the
option that warns about identifiers that are intended to denote the
same entity *and* differ in a character beyond the minimal significant
characters (six) (1). For example, the following function names with
external linkage are not strictly C90 conforming:
I couldn't agree more. Having said that, they do not /require/ the
compiler to issue a diagnostic message.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
jaysome wrote:
strictly conforming C90 compiler
In the standard,
the term "strcitly conforming" applies to programs.
Implementations of C, are either conforming or not.
--
pete This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: lkrubner |
last post by:
I've got a PHP application that's 2 megs in size. Of that, my guess is
200k-400k is comments. Do they impose a performance hit? I've been
postponing any kind of optimization, but at some point I'll...
|
by: Uwe Ziegenhagen |
last post by:
Hello,
my fellows and me implement a c++ tool that is able to divide blank/tab
separated files into <number>, <text>, <c-singlelinecomment> and
<multilinecomment>. So far it's not working bad,...
|
by: Benjamin Niemann |
last post by:
Hello,
I've been just investigating IE conditional comments - hiding things from
non-IE/Win browsers is easy, but I wanted to know, if it's possible to hide
code from IE/Win browsers.
I found...
|
by: James Hunter Ross |
last post by:
We love the ASP.NET "Session" concept and make good use of it. But, getting
close to deployment we find we lose sessions far too often, probably due to
application restarts, etc. We hope to...
|
by: Edward Elliott |
last post by:
At the risk of flogging a dead horse, I'm wondering why Python doesn't have
any multiline comments. One can abuse triple-quotes for that purpose, but
that's obviously not what it's for and doesn't...
|
by: Bob Stearns |
last post by:
Several weeks ago I asked what comments I could pass to DB2 in a SELECT
statement. I don't remember whether I said via PHP/ODBC. I was assured
that both /* */ style comment blocks and -- comment...
|
by: tjb |
last post by:
I often see code like this:
/// <summary>
/// Removes a node.
/// </summary>
/// <param name="node">The node to remove.</param>
public void RemoveNode(Node node) {
<...>
}
|
by: jacob navia |
last post by:
Recently we had poor Mr "teapot" that was horrified at the heresy
of lcc-win of accepting // comments.
C is a nice language, and you can do anything with it, inclusive a
program that transforms...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |