如何解决警告 C4067 - 预处理器后出现意外标记
我正在使用第三方库 (PCL),在编译它时,我在包含 /* Define libraries to be included */
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <ctype.h>
/* Define Structures*/
typedef struct contact {
int number; /*unique account number*/
char name[20]; /*contains name*/
char phone[15]; /*contains phone number*/
char email[20]; /*contains email address*/
struct contact *next; /*next is used to navigate through structures.*/
int count; /*count is used to input comments into array*/
} Contact;
void addNewContact(void) /* add new contact function*/
{
newRecord = (struct contact*)malloc(sizeof(struct contact));
if (firstRecord == NULL) {
firstRecord = currentRecord = newRecord;
}
else {
currentRecord = firstRecord;
while (currentRecord->next != NULL)currentRecord = currentRecord->next;
currentRecord->next = newRecord;
currentRecord = newRecord;
}
currentRecordNumber++;
printf("%27s: %5i\n","contact number",currentRecordNumber);
currentRecord->number = currentRecordNumber;
fflush(stdin);
printf("Enter contact name");
gets(currentRecord->name);/*this got skipped(no input asked)*/
fflush(stdin);
printf("Enter contact Phone number");
gets(currentRecord->phone);
fflush(stdin);
printf("Enter contact email");
gets(currentRecord->email);
fflush(stdin);
printf("contact added!");
currentRecord->count = 0;
currentRecord->next = NULL;
}
warning C4067: unexpected tokens following preprocessor directive - expected a newline
错误行指向 #if defined... 行,但我不明白意外标记在哪里。
如果我在第一个 && 之后删除所有内容(所以只保留 has_cpp_),它就可以工作。我还测试了将整个表达式放在括号中:
#if defined(__has_cpp_attribute) && __has_cpp_attribute(deprecated) && !defined(__CUDACC__)
#define PCL_DEPRECATED(message) [[deprecated(message)]]
#endif
然后我在该行收到一个更令人困惑的 #if (defined(__has_cpp_attribute) && __has_cpp_attribute(deprecated) && !defined(__CUDACC__))
#define PCL_DEPRECATED(message) [[deprecated(message)]]
#endif
错误。
这里发生了什么?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。