Concatenate in preprocessor

I am trying to concatenate two strings in a #define statement, but the preprocessor does not handle it the way I expected.
This is what I want to do:

#define MY_PATH "c:\Arduino"

#define MY_FILE_1 MY_PATH ## "file001.c"
#define MY_FILE_2 MY_PATH ## "file002.c"
etc.

I expected the ## to make the preprocessor concatenate the two, but all I get is an error message:

error: pasting "MY_PATH" and ""file001.c"" does not give a valid preprocessing token

What am I doing wrong???

It isn't clear to me what you want to do, but in C, something like the following is perfectly valid: printf ("First string" "second string\n");, so I don't see why

#define MY_PATH "c:\Arduino\"

#define MY_FILE_1 MY_PATH "file001.c"

wouldn't work

What I want to do is create a series of #define for multiple files, but I only want to specify the full path once.
So I thought making a separate #define for the path.
Then use the ## (concatenate) to paste the predefined path with the filename.

As you say, I don't see why it wouldn't work, but the compiler trips over it...

Then use the ## (concatenate)

is not a concatenate operator, it is the preprocessor stringification operator.

#define FULL_PATH(x) "/sys/bus/"x
#define PATHNAME "i2c"

void setup ()
{
  Serial.begin (9600);
  Serial.println (FULL_PATH (PATHNAME));
}

void loop ()
{
}

produces the expected "/sys/bus/i2c"

OK, if ## is not the concatenator, what is?

What would be the best way to achieve my goal?

What would be the best way to achieve my goal?

See replies #1 and #3

I figured it out. The concatenation was working just fine, but the backslashes in de path were killing me.
I replaced them by double-backslashes, and now things are working smoothly..

Put this one down to user-error... :cold_sweat:

Ah yes!
The Curse of Microsoft strikes again.

Hanselaar:
OK, if ## is not the concatenator, what is?

http://www.cplusplus.com/doc/tutorial/preprocessor/

The operator ## concatenates two arguments leaving no blank spaces between them:

#define glue(a,b) a ## b
glue(c,out) << "test";

This would also be translated into:

cout << "test";

But there's no need for an operator, as I pointed out, consecutive strings with no operator are automatically concatenated, even across newlines.

AWOL:
It isn't clear to me what you want to do, but in C, something like the following is perfectly valid: printf ("First string" "second string\n");, so I don't see why

#define MY_PATH "c:\Arduino\"

#define MY_FILE_1 MY_PATH "file001.c"


wouldn't work

This is okay

#define MY_PATH "c:\\Arduino\\"
#define MY_FILE_1 MY_PATH "file001.c"

or this

#define MY_PATH "c:/Arduino/"
#define MY_FILE_1 MY_PATH "file001.c"

character \ is special