fatal error C1189: #error: "Oops: min() and/or max() are defined as preprocessor macros. Define NOMINMAX macro before including any system headers!"
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!"的更多相关文章
- 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 ...
- VS2003转VS2010 fatal error C1189: #error
我自己的mfc的demo要转换编译环境出现以下编译错误: VS2010编译错误:fatal error C1189: #error : This file requires _WIN32_WINNT ...
- 【转】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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- fatal error C1189: #error : "No Target Architecture" 解决办法一
在编译程序的时候发现报这个错误,在网上看到很多文章,说设置include路径,lib目录等等,都没有解决.最后调整了以下include文件的顺序,问题解决了.例如 从头文件a.h中截取的一段 type ...
- 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 ...
随机推荐
- 大数据测试类型&大数据测试步骤
一.什么是大数据? 大数据是一个大的数据集合,通过传统的计算技术无法进行处理.这些数据集的测试需要使用各种工具.技术和框架进行处理.大数据涉及数据创建.存储.检索.分析,而且它在数量.多样性.速度方法 ...
- SQL Server中的锁可以分为如下几类
从大类来看,SQL Server中的锁可以分为如下几类: 共享锁(S锁):用于读取资源所加的锁.拥有共享锁的资源不能被修改.共享锁默认情况下是读取了资源马上被释放.比如我读100条数据,可以想像成读完 ...
- Mockito中的@Mock和@Spy如何使用
相同点 spy和mock生成的对象不受spring管理 不同点 1.默认行为不同 对于未指定mock的方法,spy默认会调用真实的方法,有返回值的返回真实的返回值,而mock默认不执行,有返回值的,默 ...
- centos 配置rsync+inotify数据实时同步
何为rsync? 定义: rsync是一个开源的快速备份工具,可以在不同主机之间镜像同步整个目录树,支持增量备份,保持链接和权限,非常适用于异地备份 何为源端和发起端? 在远程同步过程中,负责发起rs ...
- 关于servlet类,继承HttpServlet,但是无法导入HttpServlet包的原因和解决方法
原因:缺少tomcat的libraries(HttpServlet对应位置在tomcat的lib中====) 解决: 1. 2. 3. 4.
- CentOS 7自动以root身份登录GNOME桌面
CentOS 7自动以root身份登录GNOME桌面 修改配置文件 /etc/gdm/custom.conf,在 [daemon] 下面添加一下两行 AutomaticLoginEnable=true ...
- kubernetes资源清单之DaemonSet
什么是 DaemonSet? DaemonSet 确保全部(或者某些)节点上运行一个 Pod 的副本.当有节点加入集群时,也会为他们新增一个 Pod . 当有节点从集群移除时,这些 Pod 也会被回收 ...
- CAN学习方法(知乎)
作者:心机之花链接:https://www.zhihu.com/question/26776219/answer/244433861来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请 ...
- Git 简要教程
Git是一个管理系统,管理版本,管理内容(CMS),管理工作等. Git主要还是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. 工作流程是这样的: 克隆 Git 资源作为工作目录 ...
- jsfuck-原理
jsfuck真的fuck,第一眼就是WTF?? Example The following source will do an alert(1): [][(![]+[])[+[]]+([![]]+[] ...