1.问题描述

vs2015 使用pg数据库的C++库文件4.0.1版本libpqxx.dll,包含头文件#include "pqxx\pqxx" 出现这个错误:

fatal error C1189: #error:  "Oops: min() and/or max() are defined as preprocessor macros.  Define NOMINMAX macro before including any system headers!"

2.原因分析

图1 pqxx头文件中的定义

(1)如上图1所示,pqxx的头文件中compiler-public.hxx中有一段,如果定义了min和max,则会抛出错误。系统头文件中定义了这两个宏min和max。所以如果把pqxx包含在系统头文件之后,就会出现这个错误。所以要求吧pqxx包含在系统头文件之前。这样就不会抛出异常。

fatal error C1189: #error:  "Oops: min() and/or max() are defined as preprocessor macros.  Define NOMINMAX macro before including any system headers!"

pqxx文件定义了一些宏定义,与系统中的系统头文件的宏定义冲突,导致系统头文件编译时抛出错误;

(2)当你把pqxx包含在系统头文件之前又会出现系统头文件中找不到min和max标识符的错误,原因是图1中定义了NOMINMAX宏,使得系统头文件中的min和max无效了。

1>c:\program files (x86)\windows kits\8.1\include\um\GdiplusTypes.h(475): error C3861: “min”: 找不到标识符
1>c:\program files (x86)\windows kits\8.1\include\um\GdiplusTypes.h(476): error C3861: “min”: 找不到标识符
1>c:\program files (x86)\windows kits\8.1\include\um\GdiplusTypes.h(477): error C3861: “max”: 找不到标识符
1>c:\program files (x86)\windows kits\8.1\include\um\GdiplusTypes.h(478): error C3861: “max”: 找不到标识符
1>c:\program files (x86)\windows kits\8.1\include\um\GdiplusTypes.h(499): error C3861: “max”: 找不到标识符

(3)所以pqxx的头文件中没有定义min和max,也不需要min和max宏。和系统头文件中定义了min和max宏,也需要min和max宏。

3.解决办法

在stdafx.h头文件的最前面加上如下,先包含pqxx,放在系统头文件前面,中间取消NOMINMAX的宏定义,使得系统头文件中的min和max宏生效,再包含系统头文件,系统头文件中就可以使用min和max。

#include "pqxx\pqxx"
using namespace pqxx;
#undef NOMINMAX

自己开发了一个股票智能分析软件,功能很强大,需要的点击下面的链接获取:

https://www.cnblogs.com/bclshuai/p/11380657.html

百度云盘下载地址:

链接:https://pan.baidu.com/s/1swkQzCIKI3g3ObcebgpIDg

提取码:mc8l

微信公众号获取最新的软件和视频介绍

QStockView

fatal error C1189: #error: "Oops: min() and/or max() are defined as preprocessor macros. Define NOMINMAX macro before including any system headers!"的更多相关文章

  1. fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>

    给对话框添加类, 报错 CalibrateMFCDlg.h(6) : error C2504: “CDialog”: 未定义基类 等多个错误 加上 #include "afxwin.h&qu ...

  2. VS2003转VS2010 fatal error C1189: #error

    我自己的mfc的demo要转换编译环境出现以下编译错误: VS2010编译错误:fatal error C1189: #error : This file requires _WIN32_WINNT ...

  3. 【转】fatal error C1189: #error : missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS

    转自:http://blog.csdn.net/friendan/article/details/46576699 fatal error C1189: #error :  missing -D__S ...

  4. fatal error C1189: #error : core.hpp header must be compiled as C++

    两次opencv工程需要设置为C++编译:找了一半天的解决方法. I am building a C application that uses OpenCV. when compiling, I g ...

  5. fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC

    出现如下错误: fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires ...

  6. fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC sha

    调试程序时出现以下问题:d:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afx.h(24): fatal e ...

  7. error C2065: “CString”: 未声明的标识符 ;fatal error C1189: #error : afxstr.h can only be used in MFC proje

    转自VC错误:http://www.vcerror.com/?p=1388 问题描述: error C2065: "CString": 未声明的标识符 fatal error C1 ...

  8. fatal error C1189: #error : "No Target Architecture" 解决办法一

    在编译程序的时候发现报这个错误,在网上看到很多文章,说设置include路径,lib目录等等,都没有解决.最后调整了以下include文件的顺序,问题解决了.例如 从头文件a.h中截取的一段 type ...

  9. vc/atlmfc/include/afx.h(24) : fatal error C1189: #error : Building MFC application with /MD[d] (CRT

    环境:win7,64位,vs2012 1> c:/program files/microsoft visual studio 8/vc/atlmfc/include/afx.h(24) : fa ...

随机推荐

  1. Visual Studio 2012网站如何只生成一个DLL文件

    简介: 在Visual Studio 2005,2008,2010版本中,都有Web Deployment工具将网站进行发布,所有代码文件和库文件发布,生成为一个动态链接库文件,而在Visual St ...

  2. 【原创】运维基础之Amplify

    官方:https://www.nginx.com/products/nginx-amplify/ NGINX Amplify is a SaaS‑based monitoring tool for t ...

  3. ES6新特性总结

    一.let const var有缺陷:有块级作用域.能重复定义.无法限制修改.所以出来了let和const. 有块级作用域,不能重复定义 const不能修改,必须定义的时候赋值 二.解构赋值 1.左右 ...

  4. 在Markdown中写公式块

    Markdown是一种可以使用普通文本编辑器编写的标记语言,通过简单的标记语法,它可以使普通文本内容具有一定的格式. Markdown中的公式语法是遵循LaTex语法的 $ sum = \sum_{i ...

  5. Python实现读取Excel文档中的配置并下载软件包

    问题:现在遇到这样一个问题,服务器存储了很多软件包,这些包输入不同的产品,每个产品都有自己的配置,互相交叉,那么到底某一产品所有配置的软件包下载后,占用多大空间呢? 分析:从这个问题入手,了解到:软件 ...

  6. tomcat启动程序乱码和tomcat启动程序的标题乱码处理

    启动程序运行中的文字乱码: 解决方案: 找到Tomcat目录下conf文件夹中的logging.properties文件, 打开logging.properties文件,找到文件中的java.util ...

  7. mongodb启用auth,使用密码登录

    更新操作: db.users.update({'currentVersion':3},{$set:{'currentVersion':5}}) 首先安装下载(略过) mongod 启动服务,有多重启动 ...

  8. C# 列表中查找大小比较

    列表中查找大小比较

  9. 9.0.网络编程_IO 通信模型

    5. IO 通信模型 网络通信的本质是网络间的数据 IO.只要有 IO,就会有阻塞或非阻塞的问题,无论这个 IO 是网络的,还是硬盘的.原因在于程序是运行在系统之上的, 任何形式的 IO 操作发起都需 ...

  10. Hive的视图和索引(九)

    Hive的视图和索引 1.Hive Lateral View 1.基本介绍 ​ Lateral View用于和UDTF函数(explode.split)结合来使用. ​ 首先通过UDTF函数拆分成多行 ...