Baanboard.com

Go Back   Baanboard.com

User login

Frontpage Sponsor

Main

Poll
Would you like to see a separate forum on Baanboard for the ION product?
No
13%
Yes
87%
Total votes: 90

Baanboard at LinkedIn


Reference Content

 
Token pasting (preprocessor)
By patvdv at 26 Feb 2008 - 21:56

Token pasting (preprocessor)

In the macro, you can enter a part of a variable as a macro argument. The symbol '##' is used to distinguish macro arguments and the rest of the macro. This is omitted in the macro call. You can paste more macro arguments together as one identifier. This principle is called token pasting. It is used to reuse parts of the source code, where using functions is impossible or difficult.

Example 1

 #define p(x)       message("%d", var##x)
 #define q(x,y)       message("%d", x##y)
 #define r(x,y,z)     message("%d", x##y##z)
 long var1a, var1b
 p(1a)          | becomes: message("%d", var1a)
 p(1b)              | becomes: message("%d", var1b)
 q(var, 1a)         | becomes: message("%d", var1a)
 q(var, 1b)       | becomes: message("%d", var1b)
 r(var, 1, a)       | becomes: message("%d", var1a)
 r(var, 1, b)       | becomes: message("%d", var1b)

Example 2

 #define VRC(table,v,r,c)
 ^              tt##table##.vers = v
 ^              tt##table##.rele = r
 ^              tt##table##.cust = c

 VRC(adv100, "6.2", "a", "")
 VRC(adv200, "6.2", "a", "")
 VRC(adv300, "6.2", "a", "")

Related topics



0
No votes yet


All times are GMT +2. The time now is 09:04.


©2001-2013 - Baanboard.com - Baanforums.com