Why doesn't Xcode4 highlight syntax in conditional compilation blocks?

Example:

#ifdef FREE_VERSION tf.text = @"Free"; NSLog(@"FREE VERSION"); #else tf.text = @"Paid"; NSLog(@"PAID VERSION"); #endif 

The first part looks great in Xcode.

  tf.text = @"Free"; NSLog(@"FREE VERSION"); 

highlighted by the syntax. However, the second part is not as follows:

tf.text = @ "Paid";

NSLog (@ "PAID VERSION");

Is there such a parameter as "Do not select syntax in #else parts of the conditional signature code"?

+6
source share
2 answers

Xcode will try to determine which branch of the preprocessor will be accepted. It is expected that the branch will have syntax highlighting and the other will not.

+9
source

Most IDEs, including Xcode and Visual Studio, will not allocate code in (unoccupied) conditional blocks, because in many cases this will lead to errors that do not apply and confuse the selection. Consider using for example

 #ifdef __APPLE__ // Do something that uses apple-only headers/functions #endif #ifdef _MSVC_VER // Do something that visual studio recognizes #endif 

for code that runs on multiple platforms. Visual Studio will not know how to highlight Apple function names, and Xcode will not know what to do with Visual Studio pragmas, etc.

+3
source

Source: https://habr.com/ru/post/903537/


All Articles