How to access the $(SolutionDir) macro from C++ code.
Simply I want to get the solution directory path as a string. So that I can setup my project in any computer and get the sln directory path accordingly.
I have the same issue some time ago.
What I did was also define Preprocesor macro and with c++11 one can easily escape the problem of escapes characters. To do that go into
Properties → Configuration Properties → C/C++ → Preprocessor
There is field PreprocessorDefinitions so you need to add there:
SOLUTION_DIR=R"($(SolutionDir))"
To explain the R"()" stands for c++ string literal so there will be no problem with escape characters (they are available since C++11).
From my use case this works perfectly in Visual Studio 2015 and 2017 (should also work in 2013 and 2012. In 2010 and before there was no support for Raw String)
I solved this. Here using the $(SolutionDir) is giving the solution directory path. But there is a problem when it takes as a string because of return statement of $(SolutionDir) contains the path including slashes () without escape character.
Ex: C:\TestApp\
But to use as string it should be C:\TestApp\
Perhaps it can be used internally when setting the properties.
Related
I'm unable to compile my project due to the problem described in the title. I have a resource file with many strings, and Italian uses a lot of apostrophes in articles.
There are no double apostrophes with text inside (i.e. 'text'), all of them are single apostrophe (i. e. l'amico). All of them are correctly escaped with a backslash. Example:
<string-array name="cards">
<item>Un\'indescrivibile solitudine.</item>
</string-array>
When I click on run, it first removes all the backslahes, then it fails saying that I have unescaped apostrophes in my resource file.
I tried to clean and rebuild, but it keeps doing the same.
I'm using Android Studio 2.2.1.
I actually found the answer to my question here: https://stackoverflow.com/a/39345557/1433971 .
The problem is that when Android Studio finds the error in the string, it opens a value.xml file which it uses during the build process. I didn't notice it wasn't opening the actual file with the error and there's no reason to modify the value.xml file as it is rebuilt from your actual resource file (which is unchanged).
Please help me to solve a problem that appeared recently.
When release project is build on built machine (using msbuild) all string literals in code are escaped with \x00NN where nn are two digitals. The problem is that if such values are displayed in form (winforms) they appear as broken encoded (like broken codepage in www)
in source code it looks like
str = " Без ПДВ"
but reflector shows
str = " \x00c1\x00e5\x00e7 \x00cf\x00c4\x00c2";
And this appears as string with broken encoding in the form, like
â ò.÷. ÏÄÂ
.
What causes msbuild to convert non-ascii string literals to escaped symbols? There is no such problem for dev builds on developers machines.
Regional settings were checked for user that runs ms-build and were changed from German to Ukrainian, the same was done for non-unicode programs language. It does not help after reboot.
MsBuild has worked without such problem on the same machine for one year but latest build beraks string literals in code
command-line looks like
MSBuild {LocalPath}{Solution} /property:DefineConstants="{Defines}{DefinesExtra}" /t:{Target} /property:Configuration={Configuration} {Platform} /clp:NoItemAndPropertyList
Target is Build (or Rebuild it does not matter) configuration is release, platform is x86
PS I know that this is bad to store localized strings in code (but shit happens).
I am using F# in Visual Studio 2012 and this may seem like a dumb question but I cannot figure out how to specify include directories, specifically for binaries. I see how to do it for F# interactive using the #I directive and it works there, but the #I option is not available in the non-interactive form. The compiler error message says to use the -I compiler option. I have looked under Project Properties, where the only subsections visible are Application, Build, Build Events, Debug, and Reference Paths none of which provides any obivous way to specify an include directory path. The help system isnt much help as it seems to reference sections that are unavailable.
Well i still have the problem with VS12 but at least i have a workaround, by calling the compiler from the command line. You have to use the -r option to specify the location of the dll:
fsc -r:<complete path to dll> <fname>
However when i try the corresponding step in VS (by trying to set one of the Reference Paths) it says there are no items found in the DLL folder. So perhaps someone familiar with CS can help out
In Android.mk, I read the context of system environment variable like $(MY_ENV_VARIABLE). The env variable contains following string inside "Program(x86) Files".
But the build fails, claiming that the specified library cannot be found. The failure takes place of windows style weird space in "Program(x86) Files".
So my question is, is there any mechanism to automatically escape the special symbols like space (i.e "Program(x86)\ Files", for my case).
You might be able to try using the windows pathing conventions of using the tilde character so instead of C:\Program(x86) Files\mydir it would be C:\PROGRA~2\mydir (PROGRA~1 is for the 64 bit program files).
Like eldar said in the comments it is better to not use spaces in path names because most of make's functions use spaces as delimiters. Another option you could try is to take a look at my suggestion here: WINAVR not finding file in include path with whitespace
Since Android is a pretty complicated build environment it might be hard to see where to place the final substitution unless you know what you're doing and hopefully won't break anything else in the makefile.
This is really a follow up to the original question with this title but I am too noob to be allowed to comment there (can you merge this in as a comment Mike ?)
I just spent around a day trying to work out why I was getting this problem when I cut and pasted the command line verbatim from VS 2010 into a batch file and tried to run it.
I put the full path to link.exe in an env var in the batch file called "link" and ran the command as:
"%link%" /VERBOSE ... yada yada yada
and got the error “LNK1104: cannot open file 'C:\Program.obj'”.
This is because %link% is used by VS 2010 link.exe as additional input for linking.
As my %link% var was the program FQN "C:\Program Files\Micro$ Visual Studio 10.0..." (i.e. contains spaces), the linker tried to include "C:\Program" (as the first space delimited string), and added a suffix of ".obj" because it assumed that is what I meant.
It then tried to include this spurious file as an input, failed to find it, and fell over.
Being more of a gcc man myself, this behaviour was unexpected to say the least.
The trivial solution was to use a different name for my command variable - eg %lcmd%
Windows quoting can be a royal pain because rather than being handled by the shell, it's handled by individual programs. You may need to include appropriate quotes in the definition of %link% itself.
This error may occur when you make changes in the Linker settings which is present on the properties of the project .When you modified that path just give that path in ""(double quotes) e.g "c:\Program file\~"