I am using visual studio 2015, c++ project. In properties, C/C++, Preprocessor, I have defined a macro as follows : _SOLUTION_DIR_="$(SolutionDir)"
.
Using _SOLUTION_DIR_
in the code, I see that it's equal to "blaah\\" where the path blah
contains only "\"'s as separators between folders. This makes me having Error C2001: newline in constant
I know that the visual studio environment variable $(SolutionDir) ends with a slash, but why is only this ending backslash that is view as "\\" and not the others ? How to solve my problem ?
Here is the code :
ConvertWchartArrayToCharArray(_SOLUTION_DIR_, pFilePath, MAX_PATH);
where ConvertWchartArrayToCharArray
is defined by :
size_t ConvertWchartArrayToCharArray(const char * src, char * dest, size_t dest_len)
{
size_t i;
wchar_t code;
i = 0;
while (src[i] != '\0' && i < (dest_len - 1))
{
code = src[i];
if (code < 128)
{
dest[i] = char(code);
}
else
{
dest[i] = '?';
if (code >= 0xD800 && code <= 0xD8FF)
{
i++;
}
}
i++;
}
dest[i] = '\0';
return i - 1;
}
EDIT Now I am setting _SOLUTION_DIR_=LR"($(SolutionDir))"
and using
ConvertWchartArrayToCharArray(_bstr_t(_SOLUTION_DIR_), pFilePath, MAX_PATH);
and I have the following problem : the file path is valid with \\
separators, containing at the end the filename, but doing a fopen(filepath, "r")
give me null
...