comment style

Leif Andrew Rump andrew at resam.dk
Wed Jan 9 21:15:24 AEST 1991


In <10690 at darkstar.ucsc.edu> funkstr at ucscb.UCSC.EDU (Larry Hastings) writes:
>As for /* */ style comments, I'd just use /*/ for both ends if I could
>get away with it.  This makes it possible to have a single keymacro that emits
>both the begin and end comment markers.  Comments would now look like:

>	printf("\n");  /*/ I'm commenting this line for no reason /*/

>This works quite well with all the compilers I have handy.  The only reason I
>don't do this is because I'm afraid my coworkers would form a lynch mob.

Well our Sun C compiler which sure _isn't_ ANSI C compatible allow quite a
few things:

#include <stdio.h>

main()
{
  int   my/* Comments is _not_ considered as a white space */var;
/*
/* // It doesn't detect nested comments
  fprintf(stderr, "Hello");
/*/
  fprintf(stderr, " World");
/*/
  fprintf(stderr, "\n");
*/ 
  myvar = 1;
}

>p.s. I'm kidding about the /*/ comment markers, in case you can't tell -- but
>     I may work them in to an obfuscated C code contest entry

Does you C compiler not allow it or do You consider it bad programming?  :-)

The above code compiled on a Sun producing " World" as output. And the
comment toggling is a neat feature!!!  :-)  :-/  :-(  8-(  *-(  [Sigh]


Leif Andrew


Leif Andrew Rump, AmbraSoft A/S, Stroedamvej 50, DK-2100 Copenhagen OE, Denmark
UUCP: andrew at ambra.dk, phone: +45 39 27 11 77                /
Currently at Scandinavian Airline Systems                =======/
UUCP: andrew at resam.dk, phone: +45 32 32 51 54                \
SAS, RESAM Project Office, CPHML-V, P.O.BOX 150, DK-2770 Kastrup, Denmark

> > Read oe as: o <backspace> / (slash) and OE as O <backspace> / (slash) < <



More information about the Comp.std.c mailing list