Watcom C question - If you would be so kind

Hello,
Can anyone tell me why, when executing the following program:

#include <stdio.h>

main()
{
printf("(??)\n");
return;
}



The following is printed:

(]


in case this is hard to read, the program prints two characters, the
‘(’ left paren and the ‘]’ right bracket.

Is there some sort of preprocessor operator that I don’t know about
that operates within strings?

Thanks for your insight,
Greg Laird

??( is a “trigraph” that is equal to ] :wink:

Trigraph are character sequences allowing people that speak and write
languages or use keyboard that don’t have symbol such as [ # \ ^ etc.

I think watcom has an option to turn trigraph off.

I would guess if you use “???)” you’d be ok.

“Greg Laird” <glaird@teleport.com> wrote in message
news:3a82b340.3060378@inn.qnx.com

Hello,
Can anyone tell me why, when executing the following program:

#include <stdio.h

main()
{
printf("(??)\n");
return;
}



The following is printed:

(]


in case this is hard to read, the program prints two characters, the
‘(’ left paren and the ‘]’ right bracket.

Is there some sort of preprocessor operator that I don’t know about
that operates within strings?

Thanks for your insight,
Greg Laird

you need to escape the ? … i believe most implementations of printf
reserve that character.

e.g.
printf("(??)\n");

Greg Laird <glaird@teleport.com> wrote:

Hello,
Can anyone tell me why, when executing the following program:

#include <stdio.h

main()
{
printf("(??)\n");
return;
}



The following is printed:

(]



in case this is hard to read, the program prints two characters, the
‘(’ left paren and the ‘]’ right bracket.

Is there some sort of preprocessor operator that I don’t know about
that operates within strings?

Thanks for your insight,
Greg Laird


Randy Martin randy@qnx.com
Manager of FAE Group, North America
QNX Software Systems www.qnx.com
175 Terence Matthews Crescent, Kanata, Ontario, Canada K2M 1W8
Tel: 613-591-0931 Fax: 613-591-3579

“Greg Laird” <glaird@teleport.com> wrote in message
news:3a82b340.3060378@inn.qnx.com

Hello,
Can anyone tell me why, when executing the following program:

#include <stdio.h

main()
{
printf("(??)\n");
return;
}



The following is printed:

(]


in case this is hard to read, the program prints two characters, the
‘(’ left paren and the ‘]’ right bracket.

Is there some sort of preprocessor operator that I don’t know about
that operates within strings?

lol ! good question :slight_smile: i won several bottles of beer asking it :slight_smile:

if seriously this is from watcom help (winnt vetsion)


Trigraphs

The following is the list of trigraphs. In a C source file, all occurrences
(including inside quoted strings and character constants) of any of the
trigraph sequences below are replaced by the corresponding single character.

Trigraph
Character Sequence


[ ??(
] ??)
{ ??<
} ??>
| ??!

??=

\ ??/
^ ??’

~ ??-

No other trigraphs exist. Any question mark (?) that does not belong to one
of the trigraphs is not changed.

To get a sequence of characters that would otherwise be a trigraph, place a
\ before the second question mark. This will cause the trigraph to be
broken up so that it is not recognized, but later in the translation
process, the ? will be converted to ?. For example, ??= will be
translated to ??=.


Thanks for your insight,
Greg Laird


Ian Zagorskih
Novosoft CyBearNet Department
Custom software development and web design since 1992
E-mail: ianzag@novosoft.ru
Phone: +7 (3832) 39-72-60, 39-72-61
Fax: +7 (3832) 39-63-58
For more visit www.novosoft-us.com

“Mario Charest” <mcharest@void_zinformatic.com> wrote in message
news:95ue29$ihv$1@nntp.qnx.com

??( is a “trigraph” that is equal to ] > :wink:

Trigraph are character sequences allowing people that speak and write
languages or use keyboard that don’t have symbol such as [ # \ ^ etc.

I think watcom has an option to turn trigraph off.

I would guess if you use “???)” you’d be ok.

no, “???)” is replaced with “?]”

// wbr

“Greg Laird” <> glaird@teleport.com> > wrote in message
news:> 3a82b340.3060378@inn.qnx.com> …
Hello,
Can anyone tell me why, when executing the following program:

#include <stdio.h

main()
{
printf("(??)\n");
return;
}



The following is printed:

(]


in case this is hard to read, the program prints two characters, the
‘(’ left paren and the ‘]’ right bracket.

Is there some sort of preprocessor operator that I don’t know about
that operates within strings?

Thanks for your insight,
Greg Laird
\


Ian Zagorskih
Novosoft CyBearNet Department
Custom software development and web design since 1992
E-mail: ianzag@novosoft.ru
Phone: +7 (3832) 39-72-60, 39-72-61
Fax: +7 (3832) 39-63-58
For more visit www.novosoft-us.com

Ian M. Zagorskih <ianzag@novosoft.ru> wrote:
: if seriously this is from watcom help (winnt vetsion)

: ------

: Trigraphs

: The following is the list of trigraphs. In a C source file, all occurrences
: (including inside quoted strings and character constants) of any of the
: trigraph sequences below are replaced by the corresponding single character.

I was surprised by this, too. However, it is documented in Watcom’s C Language
Reference. (Note that QNX doesn’t include this book in its set of Watcom docs.)


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

Steve Reid <stever@qnx.com> wrote in message
news:95uggv$jgl$1@nntp.qnx.com

Ian M. Zagorskih <> ianzag@novosoft.ru> > wrote:
: if seriously this is from watcom help (winnt vetsion)

: ------

: Trigraphs

: The following is the list of trigraphs. In a C source file, all
occurrences
: (including inside quoted strings and character constants) of any of the
: trigraph sequences below are replaced by the corresponding single
character.

I was surprised by this, too. However, it is documented in Watcom’s C
Language
Reference. (Note that QNX doesn’t include this book in its set of Watcom
docs.)

They used to. I wish they still did.

Yes I know that the language spec can be found all over the place, but it’s
nice to know exactly what YOUR OWN compiler supports.

Thanks to all for your posts. I never would have thought of this. I
don’t have the Watcom Language Reference (since I have the standard
set of Watcom manuals shipped with QNX)–I wonder what other unknown
details lurk within?

Where would one get a Watcom Language Reference Manual?

Best to you,
Greg Laird


On Thu, 08 Feb 2001 15:00:01 GMT, glaird@teleport.com (Greg Laird)
wrote:

Hello,
Can anyone tell me why, when executing the following program:

#include <stdio.h

main()
{
printf("(??)\n");
return;
}



The following is printed:

(]


in case this is hard to read, the program prints two characters, the
‘(’ left paren and the ‘]’ right bracket.

Is there some sort of preprocessor operator that I don’t know about
that operates within strings?

Thanks for your insight,
Greg Laird

Trigraphs are a left over from the good old (old) days when people were
trying to use Teletypes for programming. I wouldn’t worry too much about
it.

The other useful information in the Watcom Language Reference Manual are
many of the “Implementation Dependant” things that C allows.

How bad do you really want the manual? I have one for about $10,000.00 US.
And for that I’ll throw in free overnight shipping.


Greg Laird <glaird@teleport.com> wrote in message
news:3a830128.23006768@inn.qnx.com

Thanks to all for your posts. I never would have thought of this. I
don’t have the Watcom Language Reference (since I have the standard
set of Watcom manuals shipped with QNX)–I wonder what other unknown
details lurk within?

Where would one get a Watcom Language Reference Manual?

Best to you,
Greg Laird

Bill at Sierra Design <BC@sierradesign.com> wrote:

The other useful information in the Watcom Language Reference Manual are
many of the “Implementation Dependant” things that C allows.

How bad do you really want the manual? I have one for about $10,000.00 US.
And for that I’ll throw in free overnight shipping.

Hm… that’s quite the markup. Of course, I guess old & rare does add
value, doesn’t it? :slight_smile:

-David

QNX Training Services
dagibbs@qnx.com

Well, I have one (and maybe 2) that I would let go at half of that price!
:sunglasses:

Bill at Sierra Design <BC@SierraDesign.com> wrote in message
news:95v09r$p8l$1@inn.qnx.com

Trigraphs are a left over from the good old (old) days when people were
trying to use Teletypes for programming. I wouldn’t worry too much about
it.

The other useful information in the Watcom Language Reference Manual are
many of the “Implementation Dependant” things that C allows.

How bad do you really want the manual? I have one for about $10,000.00
US.
And for that I’ll throw in free overnight shipping.


Greg Laird <> glaird@teleport.com> > wrote in message
news:> 3a830128.23006768@inn.qnx.com> …
Thanks to all for your posts. I never would have thought of this. I
don’t have the Watcom Language Reference (since I have the standard
set of Watcom manuals shipped with QNX)–I wonder what other unknown
details lurk within?

Where would one get a Watcom Language Reference Manual?

Best to you,
Greg Laird
\

Just by coincidence I downloaded clangref.pdf a few days ago. Don’t have
the exact URL, but you can start at www.openwatcom.org and work your way
from there.

regards,

rick

Greg Laird wrote:

Thanks to all for your posts. I never would have thought of this. I
don’t have the Watcom Language Reference (since I have the standard
set of Watcom manuals shipped with QNX)–I wonder what other unknown
details lurk within?

Where would one get a Watcom Language Reference Manual?

Best to you,
Greg Laird

On Thu, 08 Feb 2001 15:00:01 GMT, > glaird@teleport.com > (Greg Laird)
wrote:

Hello,
Can anyone tell me why, when executing the following program:

#include <stdio.h

main()
{
printf("(??)\n");
return;
}



The following is printed:

(]


in case this is hard to read, the program prints two characters, the
‘(’ left paren and the ‘]’ right bracket.

Is there some sort of preprocessor operator that I don’t know about
that operates within strings?

Thanks for your insight,
Greg Laird

I just dropped my price to $10 plus shipping.

Rick Lake <rwlake@SPAM.REDIRECTED.TO.DEV.NULL> wrote in message
news:3A83174C.E95F5AAF@SPAM.REDIRECTED.TO.DEV.NULL

Just by coincidence I downloaded clangref.pdf a few days ago. Don’t have
the exact URL, but you can start at > www.openwatcom.org > and work your way
from there.

regards,

rick

Or you run down to the book store and get yourself the good old
Kernighan/Ritchie: The C-Programming Language (second edition, ANSI C)
The trigraphs are an ANSI-, not a WATCOM invention.

regards,
Thomas


Bill at Sierra Design wrote:

I just dropped my price to $10 plus shipping.

Rick Lake <> rwlake@SPAM.REDIRECTED.TO.DEV.NULL> > wrote in message
news:> 3A83174C.E95F5AAF@SPAM.REDIRECTED.TO.DEV.NULL> …
Just by coincidence I downloaded clangref.pdf a few days ago. Don’t have
the exact URL, but you can start at > www.openwatcom.org > and work your way
from there.

regards,

rick

\


T. Haupt

BitCtrl Systems GmbH
Weissenfelser Str. 67
04229 Leipzig

Phone: +49 (0)341 49067 0
Phax: +49 (0)341 49067 15
eMail: frk@bitctrl.de

thomas haupt <frk@bitctrl.de> wrote:

Or you run down to the book store and get yourself the good old
Kernighan/Ritchie: The C-Programming Language (second edition, ANSI C)
The trigraphs are an ANSI-, not a WATCOM invention.

Yup, doc’ed on page 229 in the 2nd (ANSI) edition.

And, this is THE book on the C language. Well worth owning.

ISBN 0-13-110362-8

-David

QNX Training Services
dagibbs@qnx.com

Whew! I was just about ready to head to the bank for a $10,000 to buy
that manual, but I was rescued by your reference to the OpenWatcom web
site. I downloaded the manual – thanks very much!

BTW, My first edition of Kernighan and Richie says nothing about
Trigraphs. Maybe time to update my books.

Best to you,
Greg Laird


On Thu, 08 Feb 2001 23:01:48 +0100, Rick Lake
<rwlake@SPAM.REDIRECTED.TO.DEV.NULL> wrote:

Just by coincidence I downloaded clangref.pdf a few days ago. Don’t have
the exact URL, but you can start at > www.openwatcom.org > and work your way
from there.

regards,

rick

Greg Laird wrote:

Thanks to all for your posts. I never would have thought of this. I
don’t have the Watcom Language Reference (since I have the standard
set of Watcom manuals shipped with QNX)–I wonder what other unknown
details lurk within?

Where would one get a Watcom Language Reference Manual?

Best to you,
Greg Laird

On Thu, 08 Feb 2001 15:00:01 GMT, > glaird@teleport.com > (Greg Laird)
wrote:

Hello,
Can anyone tell me why, when executing the following program:

#include <stdio.h

main()
{
printf("(??)\n");
return;
}



The following is printed:

(]


in case this is hard to read, the program prints two characters, the
‘(’ left paren and the ‘]’ right bracket.

Is there some sort of preprocessor operator that I don’t know about
that operates within strings?

Thanks for your insight,
Greg Laird