PCH 警告:标头停止点不能位于宏或#if块中


今天在vs2010写了点代码,居然报了“PCH 警告:标头停止点不能位于宏或#if块中”。

/*********************
 *                   *
 * 文件夹: ▲01 绪论 *
 *                   *
 * 文件名: Scanf.c   *
 *                   *
 *********************/
#ifndef SCANF_C
#define SCANF_C

#include <stdio.h>
#include <string.h>
#include <stdarg.h>                //提供宏va_list、va_start、va_arg、va_end    
#include <ctype.h>                 //提供isprint原型 
.....

#endif 

原因:vs2010的智能感知要求.h必须以非#if系列的预编译指令打头

修改办法 两种,在代码顶部加上下面一句代码就ok了

#pragma once

 

修改后的代码

/*********************
 *                   *
 * 文件夹: ▲01 绪论 *
 *                   *
 * 文件名: Scanf.c   *
 *                   *
 *********************/
#pragma once
#ifndef SCANF_C
#define SCANF_C

#include <stdio.h>
#include <string.h>
#include <stdarg.h>                //提供宏va_list、va_start、va_arg、va_end    
#include <ctype.h>                 //提供isprint原型 

int Scanf(FILE *fp, char *format, ...)
{
    int *i;
    char *ch, *s;
    float *f;
    int count, k, len, n;        
    int tmp;
    va_list ap;
......

#endif 

将所有含有#include <***.h> 的头文件放在#ifndef等外,即上方。

//#pragma once
#include <stdio.h>
#include <string.h>
#include <stdarg.h>                //提供宏va_list、va_start、va_arg、va_end    
#include <ctype.h>                 //提供isprint原型 
#ifndef SCANF_C
#define SCANF_C

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM