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

自己编了一个股票监控软件,有如下功能,有兴趣的朋友可以下载;

(1)   个股监测。监测个股实时变化,可以监测个股大单交易、急速拉升和下降、主力入场和出场、股票最高点和最低点提醒。检测到最高点、最低点、主力进场点、主力退场点、急速拉升点、急速下跌点,给出语音或者声音提醒,不用再时刻看着大盘了,给你更多自由的时间;

(2)   大盘监测。监测大盘的走势,采用上证、深证、创业三大指数的综合指数作为大盘走势。并实时监测大盘的最高点和最低点、中间的转折点。

(3)   股票推荐。还能根据历史数据长期或短期走势进行分析,对股市3千多个股票进行分析对比,选出涨势良好的股票,按照增长速度从大到小排序,推荐给你涨势良好的股票;

下载地址:

最新版本

1.0.4版本 新增大盘和个股上下限报警功能

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

提取码:mc8l

微信公众号:QStockView

原文地址:https://www.cnblogs.com/bclshuai/p/11097547.html

时间: 2024-07-31 02:00:05

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 : missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS

转自:http://blog.csdn.net/friendan/article/details/46576699 fatal error C1189: #error :  missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS 今天使用FFMPEG出现以上错误 解决方法: 在libavutil\common.h文件头部加上以下宏定义即可: #ifdef __cplusplus#define __STDC_CONSTAN

在VC2015下编译DOOM3时发现出错fatal error C1189: #error

错误:fatal error C1189: #error :  The C++ Standard Library forbids macroizing keywords. Enable warning C4005 to find the forbidden macro. 解决方法:add "_XKEYCHECK_H" in Preprocessor Definitions 属性--配置属性-c/c++-预处理器 添加 _XKEYCHECK_H

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

给对话框添加类, 报错 CalibrateMFCDlg.h(6) : error C2504: “CDialog”: 未定义基类 等多个错误 加上 #include "afxwin.h"  就会包如上错误 fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h> 原因: 在其它文件里 #include ”CalibateMFCDlg.h&q

fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0500. Val

fatal error C1189: #error :  This file requires _WIN32_WINNT to be#defined at least to 0x0500. Value 0x0501 or higher is recommended. VS2003的工程转换成VS2010后编译报错. 定位到afxcomctl32.h文件,这是系统文件没有做任何更改,主要还是版本兼容性问题. 修改方法: 新建一个targetver.h头文件,复制以下代码: #pragma once

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 error C1189: #error :  Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD

error C1189: #error : &quot;No Target Architecture&quot;

错误信息  VS2013编译程序错误:17>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h(145): fatal error C1189: #error : "No Target Architecture" 错误原因 出现该错误是因为包含了windows自带头文件:#include "fileapi.h"双击错误信息行,页面跳转到windows头文件winnt.h中,具体信息如下: 可以看

C++编译错误 fatal error C1189: #error : The C++ Standard Library forbids macroizing keywords. Enable warning

解决方法 : 属性--配置属性-c/c++-预处理器 添加 _XKEYCHECK_H

VC6的工程转到VC2010或更高版本出现fatal error C1189编译错误的解决方法

以前也遇到过,当时解决了没写下来,这次正好又遇到了,就顺手写一下吧,别下次又忘记了. 当VC6的工程转到VC2010或更高版本时编译出现如下错误: c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxver_.h(81): fatal error C1189: #error :  Please use the /MD switch for _AFXDLL builds 很多解决方法是把工程属性中的“常规”-“MFC

error C1189以及warning MSB8012

今天在将一个VS2003的工程转化为VS2010的时候,出了一些问题. 首先是: fatal error C1189: #error :  This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended. 其次是: warning MSB8012: TargetExt(.exe) 与 Linker 的OutputFile 属性值(.scr)不匹配. 针