naruto
naruto

Reputation: 25

how to define symbols in c

I am creating cross platform code(Win and Linux) and in windowsVS the file path is usually used as

 "Folder1\\folder2\\file"

where as in gcc it should be '/' in the place of '\'

 "Folder1/folder2/file"

Can anyone suggest a way to use that or is there any #define macro that I can use in assigning this.

Although I have tried using

#if __linux__
     #define // '\'
#endif

But its throwing an error. Somebody pls help!!

Upvotes: 1

Views: 685

Answers (1)

Klas Lindbäck
Klas Lindbäck

Reputation: 33273

Use / on both platforms. The C APIs for Windows accept both / and \.

Upvotes: 4

Related Questions