zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    A
    hdu 2108 Shape of HDU(判定是不是凸多边形)
    F
    J
    扩展欧几里得
    G
    A
    D
    E
    H
  • 原文地址:https://www.cnblogs.com/CheeseIce/p/10563076.html
Copyright © 2011-2022 走看看