+ 6
Preprocessor directives
So in visual studio community DEBUG directive will be used if we are in debug, but does this mean that even exe will use everything that is in DEBUG? Now if we define wither one like TEST will this be active in release when we create exe to deploy too?
18 Answers
+ 5
Hi de do.👋
What language are you using?
Please add the language to the tags.
+ 5
de do
C# does not have marcos like C/C++.
You only have access to prrprocessors microsoft approved.
Such as:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/
+ 4
de do
It that may be true. The issue is I felt that you were using C/C++.
I felt the need to ask you for more detail, so I could know if I would be able to help you.
+ 3
I feel the same I would like him to clarify the matter.
Well for now I going to do some work.
+ 3
~ swim ~
According to this you can use preprocessors in C#.
You just cannot make your own macros.
+ 3
Just variables, no macros
+ 2
~ swim ~
I think you are right.
I will find docs on the project configuration then
+ 2
I think he is dealing with this.
https://docs.microsoft.com/en-us/cpp/build/working-with-project-properties?view=vs-2019
+ 2
Well it seems like he gave your answer the checkmark, maybe you have given the answer he wants?
He has not said if we helped him find the solution or not.
+ 2
No, no need to give me the exact example of it, I just wanted to make clear that if custom defined directive will "cut" that part of code out (#else...), Thank you
+ 2
Maybe a preprocess that acts like
if(debug_config)
{
//do stuff
}
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-if
+ 2
#if DEBUG
Console.WriteLine("Debug version");
/*set boolean variable to true, to signal
debug operations
*/
#endif
he should use this
+ 2
~ swim ~
Same for me as well. I rarely use C#.
+ 2
And that you've said to me at the beginning of this conversation, it will stay there until I remove it in the both debug and release configuration. Thank you both for your help in this matter! I am not c# programmer too, but this time I've decided to finish one small project in it.
+ 1
~ swim ~ and if I define any other one it will be active in release mode too, will it be?
+ 1
Manual it is c#, but I think it is irrelevant what language it is, isn't it?
+ 1
~ swim ~
Gave you and example of preprocessors for C/C++. What you put in the tag.
In Visual Studio "Release" and "Debug" are part of the project configurations not directive.
Since it is still unclear if you are using the correct terms or not, I will guess what you are doing.
In VS 2019 at the upper tab Below the Debug in C/C++. There is
Debug x64 |> Local Windows Debugger.
Is this what you are refering to?
+ 1
de do
bool debug = false;
#if DEBUG
Console.WriteLine("Debug version");
/*set boolean variable to true, to signal
debug operations
*/
debug = true;
#endif
This should work.