zoukankan      html  css  js  c++  java
  • [转]#define WIN32_LEAN_AND_MEAN 的作用

    今天看了用mysql的库+vc连接数据库,结果我用mfc application向导建立一个工程,然后添加#include "mysql.h"(已经设置好了环境),编译出现了一大堆错误,如下

    Compiling...
    StdAfx.cpp
    c:mysqlincludemysql_com.h(116) : error C2146: syntax error : missing ';' before identifier 'fd'
    c:mysqlincludemysql_com.h(116) : error C2501: 'SOCKET' : missing storage-class or type specifiers
    c:mysqlincludemysql_com.h(116) : error C2501: 'fd' : missing storage-class or type specifiers
    c:mysqlincludemysql_com.h(180) : error C2065: 'SOCKET' : undeclared identifier
    c:mysqlincludemysql_com.h(180) : error C2146: syntax error : missing ')' before identifier 's'
    c:mysqlincludemysql_com.h(181) : error C2059: syntax error : ')'
    Error executing cl.exe.

     

    网上找了许久,没有找到答案,我就查看了mysql根目录下的examples,里面有个工程是不是用 c++编写的,我调试了一下,居然可以编译,我就想mysql.h这个文件不会有错误,应该是编译时,include 冲突了,我就把stdafx.h那个文件删除掉几行,结果当我把#define WIN32_LEAN_AND_MEAN这几话屏蔽后,就可以编译了,我也试用了 mysql_init((MYSQL*) 0);这个函数没有问题.所以问题就出在define WIN32_LEAN_AND_MEAN这句话.

    #define WIN32_LEAN_AND_MEAN,这句的目的是指示编译器不要包含与MFC相关的操作。( 只是一个好的练习——如果你不在使用 MFC) 然后我们包括 dxutil.h ddutil.h,这是两个很有用的头文件。 他们能够使你以一种比通常的DirectX编程更轻松的方式来工作。

     

     

    为什么要  #define WIN32_LEAN_AND_MEAN

       答案很简单,因为我要包含尽量精简的内容,包含了这一句编译的时候明显快多了。

     

     

  • 相关阅读:
    [转]IUnkown生命周期管理
    [转] com 基本数据类型
    Centos 7 修改开机等待时间 Alex
    乌班图的安装常用命令 Alex
    Ubuntu切换root用户 Alex
    乌班图开启关闭防火墙 Alex
    Ubuntu远程root用户登录 Alex
    Centos 8 更改为阿里云源 Alex
    LVS调度之搭建NAT模型实现 Alex
    解决挂载mount: wrong fs type, bad option, bad superblock on Alex
  • 原文地址:https://www.cnblogs.com/foxhengxing/p/2216570.html
Copyright © 2011-2022 走看看