zoukankan      html  css  js  c++  java
  • vc一些预处理(转)

    1)
    #if defined XXX_XXX
    #endif
    是条件编译,是根据你是否定义了XXX_XXX这个宏,而使用不同的代码。

    一般.h文件里最外层的
    #if !defined XXX_XXX
    #define XXX_XXX
    #endif
    是为了防止这个.h头文件被重复include。
    #undef为解除定义,#ifndef是if not defined的缩写,即如果没有定义。
    2)
    #error XXXX
    是用来产生编译时错误信息XXXX的,一般用在预处理过程中;
    例子:
    #if !defined(__cplusplus)
    #error C++ compiler required.
    #endif

    3)
    extern 全局变量 相当于C#中的public

    4)
    __cdecl和__stdcall是两种C++函数调用规则的系统约定。
    __cdecl的:
    Argument-passing order
    Right to left

    Stack-maintenance responsibility
    Calling function pops the arguments from the stack

    Name-decoration convention
    Underscore character (_) is prefixed to names, except when exporting __cdecl functions that use C linkage.

    Case-translation convention
    No case translation

    __stdcall的:
    Argument-passing order
    Right to left.

    Argument-passing convention
    By value, unless a pointer or reference type is passed.

    Stack-maintenance responsibility
    Called function pops its own arguments from the stack.

    Name-decoration convention
    An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as int func( int a, double b ) is decorated as follows: _func@12

    Case-translation convention
    None
    5)
    #pragma pack( [ show ] | [ push | pop ] [, identifier ] , n )
    这个是用来指定类、结构的内存对齐的;
    这个说起来有点多,你上网查内存对齐能查到;

    6)
    __declspec( dllimport ) declarator
    __declspec( dllexport ) declarator
    这两个是与Dll有关的,声明可以从dll文件中输出和输入的函数、类或数据;

    7)
    #pragma once
    是规定当编译时这个文件只能被include一次;

    类似

    #if define

    8)
    disable message
    才疏学浅,没见过。。。。

    9)
    __int64
    是64位的整数类型,是为了防止32位的int不够用时用的;

    10)
    #pragma code_seg( [ [ { push | pop}, ] [ identifier, ] ] [ "segment-name" [, "segment-class" ] )
    是用来定义函数被放置在obj文件的哪个段里。

    ---------------------------------------------------

    #if defined MACRO_NAME

    #ifdef MACRO_NAME 还是稍微有点区别的。
    譬如我们公司就鼓励写第一种,因为它可以这么写:
    #if defined(MACRO_NAME) && defined(MACRO_NAME)

    这个#error是可以让用户在编译时手动产生一个编译错误,更准确的说是在预处理的时候。
    #if !defined(__cplusplus)
    #error C++ compiler required.
    #endif
    这个就是说如果你的程序不是C++的,譬如C的,就会报错。里面的错误信息是用户自己决定的。

    #pragma once基本和前面那个选择编译一样的。
  • 相关阅读:
    如何减少网页首屏加载压力和时间
    如何解决网站因图片过大加载慢的问题?
    研究首屏时间?你先要知道这几点细节
    Nginx配置location总结及rewrite规则写法
    Nginx配置文件(nginx.conf)配置详解(2)
    Nginx配置文件nginx.conf中文详解
    Linux 命令 创建文件
    【TensorFlow-windows】(五) CNN(卷积神经网络)对cifar10的识别
    【TensorFlow-windows】(四) CNN(卷积神经网络)进行手写数字识别(mnist)
    【TensorFlow-windows】(三) 多层感知器进行手写数字识别(mnist)
  • 原文地址:https://www.cnblogs.com/zhangpengshou/p/1414165.html
Copyright © 2011-2022 走看看