我试图通过使用这3个变量来定义构建的类型,但由于某种原因,它总是使用第一个。有什么想法吗?
// Pay attention: only ONE of these modes MUST be chosen.
//
//
#define DEVELOPMENT 0
#define PRODUCTION 1
#define STORE 0
这就是我使用它的方式:
#ifdef DEVELOPMENT
NSLog(@"Development version built.");
#elif STORE
NSLog(@"Store version built.");
#else
NSLog(@"Distribution version built.");
#endif
它总是进入第一个ifdef ..
答案 0 :(得分:3)
我得到了你想做的事。你必须做一点点不同的liiiitle。你必须这样做:
while (true) {
// respond to clients
Socket receiverSocket = serverSocket.accept();
System.out.println("receiver client connected!");
Socket senderSocket = serverSocket.accept();
System.out.println("sender client connected!");
ClientConnection connection = new ClientConnection(senderSocket, receiverSocket);
Thread connectionThread = new Thread(connection);
connectionThread.start();
}
如@EDUsta所述,#if DEVELOPMENT
NSLog(@"Development version built.");
#elif STORE
NSLog(@"Store version built.");
#else
NSLog(@"Distribution version built.");
#endif
检查是否完全定义了这个宏。如果是 - 那么它将被评估为#ifdef
。在您的情况下,您必须检查值,因此您必须使用true
。