473,326 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Strange C operator

I'm working on a program which has a strange operator, :>. This is
the syntax:

((unsigned short)( var1)):>((void __near *)( var2 ))

Any clue?
Jan 30 '08 #1
7 2058
In article <76**********************************@v17g2000hsa. googlegroups.com>,
<em**********@kinglibrary.netwrote:
>I'm working on a program which has a strange operator, :>. This is
the syntax:
>((unsigned short)( var1)):>((void __near *)( var2 ))
>Any clue?
ISO C 6.4.6

In all aspects of the language, these six tokens
<: :<% %%: %:%:
behave, respectively, the same as these six tokens

[ ] { } # ##

except for their spelling.

--
"All is vanity." -- Ecclesiastes
Jan 30 '08 #2
em**********@kinglibrary.net wrote:
I'm working on a program which has a strange operator, :>. This is
the syntax:

((unsigned short)( var1)):>((void __near *)( var2 ))

Any clue?
:is an alternate spelling of ] , one that can be used
even with a keyboard that lacks the ] character. The complete
list of these "digraphs" is

<: [
: ]
<% {
% }
%: #
%:%: ##

The underlying problem is that traditional C source uses
characters that are not in the "invariant subset" of the
ISO/IEC 646 character set standard; some of C's characters
are used for other purposes in local character sets. The
digraphs provide ways to spell C operators that use "variant"
characters, even on keyboards that have a Yen sign, say,
rather than one of the characters C source uses.

The odd thing is that this same problem has also been
addressed in another way, through the use of *tri*graphs:

??= #
??( [
??/ \
??) ]
??' ^
??< {
??! |
?? }
??- ~

.... which have been around since the original ANSI C Standard
and still work. Indeed, the digraphs only work in "open code"
and not in string literals and character constants:

#include <stdio.h /* these */
%:include <stdio.h /* are */
??=include <stdio.h /* equivalent */

but

puts ("#"); /* prints octothorpe */
puts ("??="); /* prints octothorpe */
puts ("%:"); /* prints percent and colon */

As far as I can see, the digraphs don't add anything that wasn't
already possible with trigraphs (or with the original large set
of C source characters, of course), but seem to have been added
just because they're thought to be more readable.

The practical value is that you can amaze your friends with
things like

%:include <stdio.h>
int main(void)
<%
printf ("O brave new world!??/n");
return 0;
??>

--
Er*********@sun.com
Jan 30 '08 #3
In article <1201727105.616296@news1nwk>,
Eric Sosman <Er*********@sun.comwrote:
>em**********@kinglibrary.net wrote:
>I'm working on a program which has a strange operator, :>. This is
the syntax:

((unsigned short)( var1)):>((void __near *)( var2 ))
:is an alternate spelling of ] , one that can be used
even with a keyboard that lacks the ] character.
But that doesn't look like a plausible explanation in this case, since
a ] character would make no sense.

And the __near suggests it's not exactly portable C. Perhaps the
OP could post a larger fragment, and explain where the code comes from?

-- Richard
--
:wq
Jan 30 '08 #4
Richard Tobin wrote:
In article <1201727105.616296@news1nwk>,
Eric Sosman <Er*********@sun.comwrote:
>em**********@kinglibrary.net wrote:
>>I'm working on a program which has a strange operator, :>. This is
the syntax:

((unsigned short)( var1)):>((void __near *)( var2 ))
> :is an alternate spelling of ] , one that can be used
even with a keyboard that lacks the ] character.

But that doesn't look like a plausible explanation in this case, since
a ] character would make no sense.
Plausible or not, ] is what it is. Maybe the O.P.'s
attention was drawn to this line because the compiler honked
about a syntax error?
And the __near suggests it's not exactly portable C. Perhaps the
OP could post a larger fragment, and explain where the code comes from?
It'd be nice to see a little more context, yes. Something
about the identifiers and the lavish use of parentheses suggests
that what we see is snipped from the middle of a macro definition.

--
Er*********@sun.com
Jan 30 '08 #5
In article <1201735819.744335@news1nwk>,
Eric Sosman <Er*********@sun.comwrote:
>>>I'm working on a program which has a strange operator, :>. This is
the syntax:

((unsigned short)( var1)):>((void __near *)( var2 ))
>> :is an alternate spelling of ] , one that can be used
even with a keyboard that lacks the ] character.
>But that doesn't look like a plausible explanation in this case, since
a ] character would make no sense.
Plausible or not, ] is what it is.
If the code is, in fact, intended to be (post-digraph) standard C,
rather than some other C-like language, and has not been damaged in
transit (e.g. by character set conversion).

Of course, it could just be a smiley :>

-- Richard
--
:wq
Jan 30 '08 #6
Eric Sosman <Er*********@sun.comwrites:
Richard Tobin wrote:
>In article <1201727105.616296@news1nwk>,
Eric Sosman <Er*********@sun.comwrote:
>>em**********@kinglibrary.net wrote:
I'm working on a program which has a strange operator, :>. This is
the syntax:

((unsigned short)( var1)):>((void __near *)( var2 ))
>> :is an alternate spelling of ] , one that can be used
even with a keyboard that lacks the ] character.

But that doesn't look like a plausible explanation in this case, since
a ] character would make no sense.

Plausible or not, ] is what it is. Maybe the O.P.'s
attention was drawn to this line because the compiler honked
about a syntax error?
[...]

It's ] *if* the compiler supports it. Digraphs were introduced in the
C95. It's conceivable that the compiler is an old one that doesn't
support digraphs, but has some other extension that uses :>. That
doesn't seem likely, though.

Yes, more context would be helpful.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jan 31 '08 #7
I'm getting this when I try to compile:
error C2215: ':>' operator only for objects based on 'void'
This is the line that's blowing up:

return (BYTE *) MAKE_FAR (0x34, address);
And this is the macro that defines the thing:

#define MAKE_FAR( var1, var2) (((unsigned short)( var1)):>((void
__near *)( var2 )))

Jan 31 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ben | last post by:
Hi all, I'm trying to figure out how how complex map, filter and reduce work based on the following piece of code from http://www-106.ibm.com/developerworks/linux/library/l-prog.html : ...
2
by: Jason Heyes | last post by:
The following program does not compile. Apparantly "t" is inaccessible. #include <iostream> using namespace std; template <class T> class Foo { T t; public: Foo(T t_) : t(t_) { }
2
by: Gernot Frisch | last post by:
This code: class A { #define MK_OPERATOR_CL(zz) \ DGStr& operator zz=(const DGStr& a); \ DGStr& operator zz=(int a); \ DGStr& operator zz=(float a); \ DGStr& operator zz=(double a); ...
4
by: Prawit Chaivong | last post by:
Hi, gurus I've overloaded new operator. and I found that size is strange. It's more than sizeof(myClass) 4 bytes. Where does it come from. I don't know the other compilers do the same thing....
2
by: Olaf | last post by:
I have a frameset page witch contains the myFuc() function. The function is accessed from a page in one of the frames in the frameset. An example is shown below. <input...
3
by: Bruno van Dooren | last post by:
Hi All, i have some (3) different weird pointer problems that have me stumped. i suspect that the compiler behavior is correct because gcc shows the same results. ...
7
by: dam_fool_2003 | last post by:
#include<stdio.h> int main(void) { unsigned int a=20,b=50, c = sizeof b+a; printf("%d\n",c); return 0; } out put: 24
4
by: Harlan Messinger | last post by:
Since operator overloads into static functions in C#, there really doesn't need to be a connection between the types to which the operator is being applied and the type in which the overload is...
4
by: Yuri CHUANG | last post by:
This is a example from a textbook,but there are some strange error that I don't understand.Could anyone give me some help to realize the operations on set.Thank you very much:-) (I compile it with...
28
by: charlie | last post by:
Hi, I found an article on informit.com that talks about C++ casts http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=285&rl=1 The strange thing is the author says the following...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
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...
0
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...
0
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
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)...
1
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.