Is there anything like the token pasting operator (##) in C#?
I'm trying to port some unmanaged C++ code into C# and I'm not sure
how to mimic this behavior. 4 3420
Hi,
In C++, this is a pre-processor operator, not a language operator. C#'s
pre-processor is quite minimalistic and, unfortunately, has no equivalent of
the ## operator. You can probably do the preprocessor's work yourself and
merge the tokens manually.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Nelson Hsu" <ne****@ccls.com> wrote in message
news:c4**************************@posting.google.c om... Is there anything like the token pasting operator (##) in C#?
I'm trying to port some unmanaged C++ code into C# and I'm not sure how to mimic this behavior.
Dmitriy Lapshin [C# / .NET MVP] <x-****@no-spam-please.hotpop.com>
wrote: In C++, this is a pre-processor operator, not a language operator. C#'s pre-processor is quite minimalistic and, unfortunately, has no equivalent of the ## operator. You can probably do the preprocessor's work yourself and merge the tokens manually.
I'm not sure I'd say it's unfortunate - while I haven't used token
pasting, it certainly *sounds* like the kind of thing which would make
the code hard to read. I for one am glad that the "preprocessor" in C#
is so minimal.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jon,
When I said "unfortunately", I meant "unfortunately for the original poster"
as Mr. Hsu would need to do the pasting manually if he is to port the code
to C#.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Dmitriy Lapshin [C# / .NET MVP] <x-****@no-spam-please.hotpop.com> wrote: In C++, this is a pre-processor operator, not a language operator. C#'s pre-processor is quite minimalistic and, unfortunately, has no
equivalent of the ## operator. You can probably do the preprocessor's work yourself
and merge the tokens manually.
I'm not sure I'd say it's unfortunate - while I haven't used token pasting, it certainly *sounds* like the kind of thing which would make the code hard to read. I for one am glad that the "preprocessor" in C# is so minimal.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
It does make the code extremely difficult to read. The original coder
must have been on crack...or a deadline. Anyways thanks for your
guys' help! Looks like I'll have to manually do this.
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:<O$**************@TK2MSFTNGP09.phx.gbl>... Jon,
When I said "unfortunately", I meant "unfortunately for the original poster" as Mr. Hsu would need to do the pasting manually if he is to port the code to C#.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx Bring the power of unit testing to VS .NET IDE
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message news:MP************************@msnews.microsoft.c om... Dmitriy Lapshin [C# / .NET MVP] <x-****@no-spam-please.hotpop.com> wrote: In C++, this is a pre-processor operator, not a language operator. C#'s pre-processor is quite minimalistic and, unfortunately, has no equivalent of the ## operator. You can probably do the preprocessor's work yourself and merge the tokens manually.
I'm not sure I'd say it's unfortunate - while I haven't used token pasting, it certainly *sounds* like the kind of thing which would make the code hard to read. I for one am glad that the "preprocessor" in C# is so minimal.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Cronus |
last post by:
Hi
the following code the g++ (g++ (GCC) 3.3.3 (Debian 20040422)) emits the
error message that pasting of :: and hello is no valid preprocessor token.
The g++ 2.95.3 accepts the code. I know...
|
by: Frodo Baggins |
last post by:
Hi All,
I have a piece of code (not written by me) that is failing on compile with
the error:
pasting "xdr_ndmp_connect_open_request" and "," does not
give a valid preprocessing token
The...
|
by: Chris |
last post by:
Hi all
We have a strange problem with macros:
#define SQLST_MAP_IND_O(Tbl,Fld) i##Tbl##_O=i##Tbl##_##Fld;
SQLST_MAP_IND_I(RAGREEJ1,FORMFROMTMSTP);
=> gcc 3.3.4 gives the following error:...
|
by: Wessi |
last post by:
Hi,
token pasting means, that normally whitespaces and comments are deleted
before and after the ## operator. I want the preprocessor to hold an
existing whitespace while replacing the argument...
|
by: Mark Odell |
last post by:
I'm running two different compilers against some hairy macros and one,
gcc, doesn't like my token pasting result so much. It says, " "." and
"foo" does not give a valid preprocessing token ". Some...
|
by: Henry Townsend |
last post by:
I hope this is on-topic in c.l.c - it's about the C preprocessor more
than the language per se, more generally about the K&R behavior, and
most specifically about the Sun cpp which is why I've...
|
by: mark.bergman |
last post by:
I am porting some old code from Digital Unix to Linux using token
pasting, which is failing to compile (code simplified):
#define DEBUG(strg,v) printf("debugoutput: "##strg##".\n", v);
main()...
|
by: Rudhir |
last post by:
Hi Everyone,
How can I paste tokens with a white space between them?
Because,
#define Paste(a,b) (a ## b)
doesn't put a white space between the tokens.
|
by: jeff |
last post by:
Given:
===Program <===
$ cat macro_delay_expansion.c
#define args(a,b) a, b
#define myprintf(a, b, c) do { \
printf("%d %d %d\n", a, b, c );\
} while(0)
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |