LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI2013 f1 and preprocessor ## directive

Solved!
Go to solution

CVI2013 with f1 gives build error for preprocessor ## directive (token concatenation).

 

See attachment

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 1 of 6
(4,964 Views)

I don't understand what you mean with that link, sorry.

Could you explain it, please?

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 3 of 6
(4,889 Views)
Solution
Accepted by vix

You are wrongly using the ## operator. 

The ## operator is called also "token pasting operator" and its purpose is to tell to C preprocessor to concatenate two tokens.

 

You want simply to concatenate two strings: you don't need any special operator:

 

#define LocalDir   "E:\\"  SharedDir        // define

 

 

 

Carlo A.
Megaris




Message 4 of 6
(4,876 Views)

Now I understand what you mean, and I tried that your suggestion works in CVI 2013

 

#define str1    "abcd"
#define str2    "efgh"

#define concatenated_string    str1 str2   //using a space character between the 2 strings

 

 

I don't know why ## has been working for string concatenation since CVI 6.0 to CVI 2012 SP1 Smiley Surprised

I've been using it since years (I supposed that a string is a simple token, but probably it isn't)

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 5 of 6
(4,806 Views)

Hi

Keep in mind that this is a general feature of string literals, and not something related to preprocessor directives, so you could, for example, write something like this:

 

printf("this "
       "is "
       "a single "
       "long "
       "string");

 

Carlo A.
Megaris




0 Kudos
Message 6 of 6
(4,796 Views)