How to get MSVS to recognized the bigobj flag? - c++

I am building a User Defined Function in ANSYS Fluent which calls my installation of MSVS 2017 to compile the code. The problem is I get the error:
fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj
I have found others with this problem, but I still have not been able to figure out how to add a line in my code to get the compiler to recognize this. Based on finding other snippets of code online, I have tried to add the lines after the includes at the top of the code:
#include "udf.h"
#include "unsteady.h"
#include "dynamesh_tools.h"
ADD_DEFINITIONS(/bigobj)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
But this gives the errors:
..\..\src\MY_UDF.c(10): error C2143: syntax error: missing ')' before '/'
..\..\src\MY_UDF.c(10): error C2143: syntax error: missing '{' before '/'
..\..\src\MY_UDF.c(10): error C2059: syntax error: '/'
..\..\src\MY_UDF.c(10): error C2059: syntax error: ')'
I don't understand these errors, as these were copied from someone else's working code. I also tried, from a different snippet I found online:
QMAKE_CXXFLAGS += -bigobj
But this gives the error below.
..\..\src\MY_UDF.c(9): error C2143: syntax error: missing '{' before '+='
..\..\src\MY_UDF.c(9): error C2059: syntax error: '+='
This is the top of my udf file, which runs until I add too many lines to it and get the error shown above.
#include "udf.h"
#include "unsteady.h"
#include "dynamesh_tools.h"
I expect the code to compile but it doesn't. I have not found any solution that shows exactly how to tell the compiler what it tells me I should tell it.

Your answer is in the link below, you must just add a /bigobj to the makefile_nt.udf file of Fluent! Thats really a life saver!
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/5043c081-a317-4528-a02d-d4b6e6d21543/problem-with-bigobj-when-compiled-by-other-software?forum=msbuild

Related

Error D8003: missing source filename and CMap

I'm working on a C++ solution. It builds and runs just fine on my main computer, but transferring it to a different computer results in those build errors:
Error D8003: missing source filename in cl
Error C2143: syntax error : missing ';' before '<' at the declaration of a CMap in the header file.
Could someone direct me to the possible causes of this?
It does seem that you need to have #include <afxtempl.h> in your src/header file.

Winbase.h doesn't support in creating DLL file

I would like to create a project use to call c++ method using c#. So, I need to create a dll file for all of my c++ function. But when i get an error in y sqlite source code such as "AreFileApisASNSI undeclared identifier". So, i import winbase.h which is part of the mingw-w64 runtime package to my visual studio 2012 express DLL project. After import the file, I get many errors such as below:-
error c4430: missing type specifier - int assumed. Note: C++ does not support default - int
error C2143: syntax error : missing ';' before '_stdcall'
error c1003 error count exceeds 100; stopping compilation
error c2061: syntax error: identifier ' WINBOOL'
error c2086: 'int_CRT_INLINE' : redefinition
error c2143: syntax error: missing ';' before ''
error C2146: syntax error : missing ';' before identifier 'LONGLONG'
error C2146: syntax error : missing ';' before identifier 'PVOID'
any solution for those error? please help!!
The documentation for the function has this header requirement:
WinBase.h (include Windows.h)
This is telling you that the function is declared in WinBase.h, but that you should include Windows.h which in turn will include WinBase.h. So, you need to change your include to
#include <Windows.h>
I also wonder why you are talking about mingw considering that your compiler is MSVC. That compiler ships with a comprehensive Windows SDK. Why would you be using an SDK from mingw?

Qt QPainterpath.h errors

I am currently working on a Qt application with many #include files from the Qt library. The project is quite large and I have encountered a strange problem when building. The errors displayed are all inside the QPainterpath.h file, but has nothing to do with calls to it from my project. The errors all look like this:
c:\qt\4.8.4\include\qtgui../../src/gui/painting/qpainterpath.h(397) : error C2143: syntax error : missing ';' before '::'
c:\qt\4.8.4\include\qtgui../../src/gui/painting/qpainterpath.h(397) : error C2059: syntax error : '::'
c:\qt\4.8.4\include\qtgui../../src/gui/painting/qpainterpath.h(398) : error C2143: syntax error : missing ';' before '{'
c:\qt\4.8.4\include\qtgui../../src/gui/painting/qpainterpath.h(398) : error C2447: '{' : missing function header (old-style formal list?)
c:\qt\4.8.4\include\qtgui../../src/gui/painting/qpainterpath.h(405) : warning C4003: not enough actual parameters for macro 'elementCount'
I encountered this once before and was able to solve it by moving some Qt #include statements called before other class headers below them. I can't seem to figure out what in particular is causing it this time though. Any thoughts would be great!
Thanks!
I've seen this happen when you forget to close a class definition with a semicolon. If you look at the output from the compiler, and see which file was compiled right before this error started, you may have your answer. Look for syntax errors with missing a ; or an extra } or a missing } at the end of the previously compiled file.
It could also be from a .h file listed above your #include <QPainter> call that has the errors.
Hope that helps.
I'm working with RyGuyFalcore and figured out why this is happening in our code, and nobody else is seeing it. The issue is that our legacy code was redefining the elementCount macro. Therefore, if we included that portion of our legacy code before we included the Qt code, the wrong macro was getting used :( Figured I would post this here to avoid any wild goose chase that others may run into if they hit a similar bug.

Visual studio compiler errors at enum

I have the following code which compiles without errors under Linux and Mac OS X. I now want to compile the code with Windows, but I get a lot of errors in the following code segment:
...
enum Type
{
UPDATE = 0, DELETE = 1
};
...
The error messages are these:
1>Request.hpp(48) : error C2143: syntax error : missing '}' before '('
1>Request.hpp(48) : error C2059: syntax error : '<L_TYPE_raw>'
1>Request.hpp(49) : error C2143: syntax error : missing ';' before '}'
1>Request.hpp(49) : error C2238: unexpected token(s) preceding ';'
What did I wrong, I am really confused, as this compiles without errors under Linux.
What can cause this errors?
The solution is quite easy, but one need to find out that DELETE is a Macro defined in the windows header.
I now added #undef DELETE and it works fine.
Type is an existing class. You need to change the name or specify that it's a literal.
You could try enum #Type to specify a literal, though you may need to prefix it with # elsewhere.

missing ';' before namespace when using boost 1.4.2

Working on moving some C++ code from Linux over to Windows. The code uses boost 1.4.2, however it keeps failing out on building the boost modules. Basically, every boost hpp file that happens to contain "namespace boost" errors with:
error C2143: syntax error : missing ';' before 'namespace'
Any idea what could be causing this?
Loss of ; before including Boost header could be cause of that. The following code produce such error:
struct X {} // << ; lost here
#include <boost/shared_ptr.hpp>
This small code gives me the following error:
boost/config/suffix.hpp(460) : error C2143: syntax error : missing ';' before 'namespace'
Have you tried including these boost headers on the first line? If they compile fine that way, it's likely a missing ; in one of the headers included before them.