MySQL++

View Ticket
Login
Ticket Hash: d90247c72808a8e7cb5c3b910e6b7a96e46d8d12
Title: Warnings compiling in Windows with MingW
Status: Closed Type: Incident
Severity: Minor Priority: High
Subsystem: Documentation Resolution: Fixed
Last Modified: 2023-10-16 12:31:49
Version Found In: 3
User Comments:
anonymous added on 2023-07-24 10:16:09:
When compiling applications that use MySQL++ with MingW (GNU-C for Windows), two warnings appear that can be avoided:

Warning 1:
	C:\MySQL++\3.3.0\include/common.h:56: warning: "NOMINMAX" redefined
		56 |  #define NOMINMAX
Solution: We can prevent this by changing "common.h" with when #defining NOMINMAX:

	//Don't define NOMINMAX when compiling with GNU C (MingW)
	#if !defined (__GNUC__)
		// Don't let windows.h (via Connector/C) #define min/max
		#define NOMINMAX
	#endif

Warning 2: "warning: type attributes ignored after type is already defined [-Wattributes]"
	This warning appears in several files, for example:
		C:\MySQL++\3.3.0\include/cpool.h:42:22: warning: type attributes ignored after type is already defined [-Wattributes]
			42 | class MYSQLPP_EXPORT Connection;
Solution: Changing the definition of MYSQLPP_EXPORT in common.h:

	// Define DLL import/export tags for Windows compilers, where we build
	// the library into a DLL, for LGPL license compatibility reasons.
	// (This is based on a similar mechanism in wxWindows.)
	#if defined (__GNUC__)
		//Don't set DLL import/export tags for GNU C (MingW)
		#define MYSQLPP_EXPORT
	#else 
		#ifdef MYSQLPP_MAKING_DLL
			// When making the DLL, export tagged symbols, so they appear
			// in the import library.
			#define MYSQLPP_EXPORT __declspec(dllexport)
		#elif !defined(MYSQLPP_NO_DLL)
			// We must be _using_ the DLL, so import symbols instead.
			#define MYSQLPP_EXPORT __declspec(dllimport)
		#else
			// Not making a DLL at all, so no-op these declspecs
			#define MYSQLPP_EXPORT
		#endif
	#endif

Hope this helps!
M