Veins 4.7 Omnet++ 5.3 build error in windows 7 - c++

I am new to vein and omnet++. I followed this tutorial http://veins.car2x.org/tutorial/ everything works up to step 3, for some reason veins 4.7 doesn't build in omnet++ 5 (IDE) and generates the following errors.
veins/modules/utility/TimerManager.cc
In file included from veins/modules/utility/TimerManager.cc:20:
.\veins/modules/utility/TimerManager.h:137:26: error: expected identifier
enum class StartMode { RELATIVE, ABSOLUTE, IMMEDIATE };
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1434:18: note: expanded from macro 'RELATIVE'
#define RELATIVE 2
^
In file included from veins/modules/utility/TimerManager.cc:20:
.\veins/modules/utility/TimerManager.h:137:36: error: expected identifier
enum class StartMode { RELATIVE, ABSOLUTE, IMMEDIATE };
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
^
In file included from veins/modules/utility/TimerManager.cc:20:
.\veins/modules/utility/TimerManager.h:138:24: error: expected identifier
enum class EndMode { RELATIVE, ABSOLUTE, REPITITION, OPEN };
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1434:18: note: expanded from macro 'RELATIVE'
#define RELATIVE 2
^
In file included from veins/modules/utility/TimerManager.cc:20:
.\veins/modules/utility/TimerManager.h:138:34: error: expected identifier
enum class EndMode { RELATIVE, ABSOLUTE, REPITITION, OPEN };
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
^
veins/modules/utility/TimerManager.cc:42:28: error: expected unqualified-id
start_mode_ = StartMode::RELATIVE;
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1434:18: note: expanded from macro 'RELATIVE'
#define RELATIVE 2
^
veins/modules/utility/TimerManager.cc:48:28: error: expected unqualified-id
start_mode_ = StartMode::ABSOLUTE;
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
^
veins/modules/utility/TimerManager.cc:54:24: error: expected unqualified-id
end_mode_ = EndMode::RELATIVE;
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1434:18: note: expanded from macro 'RELATIVE'
#define RELATIVE 2
^
veins/modules/utility/TimerManager.cc:60:24: error: expected unqualified-id
end_mode_ = EndMode::ABSOLUTE;
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
^
veins/modules/utility/TimerManager.cc:86:19: error: expected unqualified-id
case StartMode::RELATIVE:
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1434:18: note: expanded from macro 'RELATIVE'
#define RELATIVE 2
^
veins/modules/utility/TimerManager.cc:88:30: error: expected unqualified-id
start_mode_ = StartMode::ABSOLUTE;
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
^
veins/modules/utility/TimerManager.cc:90:19: error: expected unqualified-id
case StartMode::ABSOLUTE:
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
^
veins/modules/utility/TimerManager.cc:98:17: error: expected unqualified-id
case EndMode::RELATIVE:
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1434:18: note: expanded from macro 'RELATIVE'
#define RELATIVE 2
^
veins/modules/utility/TimerManager.cc:100:26: error: expected unqualified-id
end_mode_ = EndMode::ABSOLUTE;
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
^
veins/modules/utility/TimerManager.cc:102:17: error: expected unqualified-id
case EndMode::ABSOLUTE:
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
^
veins/modules/utility/TimerManager.cc:106:26: error: expected unqualified-id
end_mode_ = EndMode::ABSOLUTE;
^
C:\Users\Abu\src\omnetpp-5.3\tools\win64\mingw64\x86_64-w64-mingw32\include\wingdi.h:1433:18: note: expanded from macro 'ABSOLUTE'
#define ABSOLUTE 1
^
15 errors generated.
make[1]: *** [Makefile:205: ../out/clang-debug/src/veins/modules/utility/TimerManager.o] Error 1
make[1]: Leaving directory '/c/Users/Abu/src/veins-4.7/src'
make: *** [Makefile:12: all] Error 2
I am also using sumo_win64_0.32.0. I am not sure what causes these errors.
Any help is greatly appreciated.

The issue has been fixed in this pull request and a new minor revision of Veins (i.e. Veins 4.7.1) has been released. Please download the new version to get the fix and also some additional improvements.

I just encountered that error as well and here is what happens:
The compiler cannot resolve the enum class definitions in TimerManager.h as there is a name ambiguity with the macros RELATIVE and ABSOLUTE within wingdi.h
enum class StartMode { RELATIVE, ABSOLUTE, IMMEDIATE };
enum class EndMode { RELATIVE, ABSOLUTE, REPITITION, OPEN };
Quick fix is to rename the occurrences in TimerManager.h and TimerManager.cc to something else. E.g. Replace all occurrences of RELATIVE with RELATIVEINS and ABSOLUTE with ABSOLUTEVEINS etc... (or whatever you like). Worked fine for me with 4.7 and OMNet++ 5.2.1.

A patch is required to make Veins 4.7 compile with OMNeT++ 5.3 for Windows. The cleanest way may be something like on https://pastebin.com/ymzqMpEF
- enum class StartMode { RELATIVE, ABSOLUTE, IMMEDIATE }
+ enum class StartMode { relative, absolute, immediate }
that is, renaming the all-uppercase enum class constants to lower case ones (something recommended by many coding styles as well).

Related

Compile errors in Tensorflow Lite Micro framework when trying to integrate Tensorflow Lite Micro to my ESP32 Arduino project

Hi stackoverflow community,
I am trying to get a project leveraging Tensorflow Lite Micro to run on my ESP32 using PlatformIO and the Arduino framework (not ESP-IDF). Basically, I followed the guide in this medium post https://towardsdatascience.com/tensorflow-meet-the-esp32-3ac36d7f32c7 and then included everything in my already existing ESP32 project.
My project was compiling fine prior to the integration of Tensorflow Lite Micro but since integrating it, I am getting the following compile errors which seem to be related to the Tensorflow framework itself. When I uncomment everything related to Tensorflow, it compiles fine. But just when only including the following header files, it breaks:
#include "tensorflow/lite/micro/kernels/micro_ops.h"
#include "tensorflow/lite/micro/micro_error_reporter.h"
#include "tensorflow/lite/micro/micro_interpreter.h"
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/version.h"
Does someone know where these errors come from and what I can do to solve those?
Here is the error trace:
In file included from /Users/XXX/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiClient.h:24:0,
from /Users/XXX/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFi.h:37,
from src/main.cpp:3:
/Users/XXX/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:64:17: error: expected identifier before numeric constant
#define DEFAULT 1
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:31:5: note: in expansion of macro 'DEFAULT'
DEFAULT = 1,
^
/Users/XXX/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:64:17: error: expected '}' before numeric constant
#define DEFAULT 1
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:31:5: note: in expansion of macro 'DEFAULT'
DEFAULT = 1,
^
/Users/XXX/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:64:17: error: expected unqualified-id before numeric constant
#define DEFAULT 1
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:31:5: note: in expansion of macro 'DEFAULT'
DEFAULT = 1,
^
In file included from lib/tfmicro/tensorflow/lite/micro/micro_interpreter.h:24:0,
from src/main.cpp:12:
lib/tfmicro/tensorflow/lite/core/api/profiler.h:51:21: error: declaration of '~tflite::Profiler' as non-member
virtual ~Profiler() {}
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:61:48: error: 'EventType' has not been declared
virtual uint32_t BeginEvent(const char* tag, EventType event_type,
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:63:54: error: 'virtual' outside class declaration
int64_t event_metadata2) = 0;
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:63:58: error: function 'uint32_t tflite::BeginEvent(const char*, int, int64_t, int64_t)' is initialized like a variable
int64_t event_metadata2) = 0;
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:65:40: error: 'EventType' has not been declared
uint32_t BeginEvent(const char* tag, EventType event_type,
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:74:48: error: 'virtual' outside class declaration
int64_t event_metadata2) {}
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:76:46: error: 'virtual' outside class declaration
virtual void EndEvent(uint32_t event_handle) = 0;
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:76:50: error: function 'void tflite::EndEvent(uint32_t)' is initialized like a variable
virtual void EndEvent(uint32_t event_handle) = 0;
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:85:34: error: 'EventType' has not been declared
void AddEvent(const char* tag, EventType event_type, uint64_t start,
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h: In function 'void tflite::AddEvent(const char*, int, uint64_t, uint64_t, int64_t)':
lib/tfmicro/tensorflow/lite/core/api/profiler.h:88:35: error: too many arguments to function 'void tflite::AddEvent(const char*, int, uint64_t, uint64_t, int64_t)'
/*event_metadata2*/ 0);
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:85:8: note: declared here
void AddEvent(const char* tag, EventType event_type, uint64_t start,
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h: At global scope:
lib/tfmicro/tensorflow/lite/core/api/profiler.h:91:42: error: 'EventType' has not been declared
virtual void AddEvent(const char* tag, EventType event_type, uint64_t start,
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:93:48: error: 'virtual' outside class declaration
int64_t event_metadata2) {}
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:95:2: error: expected unqualified-id before 'protected'
protected:
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:105:25: error: expected ')' before '*' token
ScopedProfile(Profiler* profiler, const char* tag,
^
src/main.cpp:202:1: error: expected '}' at end of input
}
^
src/main.cpp:202:1: error: expected unqualified-id at end of input
*** [.pio/build/esp32cam/src/main.cpp.o] Error 1
Today I faced a similar problem. I solved it by using TensorFlowLite_ESP32 library instead of Arduino_TensorFlowLite. You need to download this library and add the line #include <TensorFlowLite_ESP32.h>. I hope this helps you too
I resolved this for now by switching from the Arduino framework to the ESP-IDF framework. With this, it works like a charm.

C++ project with Objective-C++ framework import fails to build

I have a CMake C++ project which targets mac, which has a .h header file that includes the following import.
#import <Foundation/Foundation.h>
When I try to build the project, I get the following compiler error:
In file included from /Users/ram/development/foo/mac/FooComponent.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:8:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:492:1: error: expected unqualified-id
#class NSString, Protocol;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:503:50: error: unknown type name 'Protocol'
FOUNDATION_EXPORT NSString *NSStringFromProtocol(Protocol *proto) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:504:19: error: unknown type name 'Protocol'
FOUNDATION_EXPORT Protocol * _Nullable NSProtocolFromString(NSString *namestr) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:508:53: error: format argument not an NSString
FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2) NS_NO_TAIL_CALL;
~~~~~~~~~~~~~~~~ ^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:94:49: note: expanded from macro 'NS_FORMAT_FUNCTION'
#define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString__, F, A)))
^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:509:63: error: format argument not an NSString
FOUNDATION_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0) NS_NO_TAIL_CALL;
~~~~~~~~~~~~~~~~ ^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:94:49: note: expanded from macro 'NS_FORMAT_FUNCTION'
#define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString__, F, A)))
^ ~
I've tried updating the project's CMakeLists.txt to pass `"-framework Foundation" but somehow CMake filters out that library from the build.
Does anyone know what might be the root cause, and how to fix it?

What causes my "‘FatalError’ in namespace ‘Foam’ does not name a type" error?

I have a strange error that I did not manage to solve for some time now. I want to extend one C++ software package by using it together with Intel OpenVINO's inference engine. Therefore I have to dynamically link some libraries and include some headers into the existing code. Before, it compiles without any errors. Then I include the first header file (#include "inference_engine.hpp") which is found, but I get this error message
In file included from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/VectorSpaceI.H:26:0,
from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/VectorSpace.H:230,
from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/Vector.H:44,
from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/vector.H:39,
from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/fieldTypes.H:35,
from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/primitiveFieldsFwd.H:36,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.H:44,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:31:
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:316:13: error: ‘FatalError’ in namespace ‘Foam’ does not name a type
::Foam::FatalError((functionName), __FILE__, __LINE__)
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:358:5: note: in expansion of macro ‘FatalErrorIn’
FatalErrorIn(functionName) \
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:367:24: note: in expansion of macro ‘notImplemented’
#define NotImplemented notImplemented(FUNCTION_NAME)
^
/opt/intel_openvino/openvino/inference_engine/include/ie_common.h:210:7: note: in expansion of macro ‘NotImplemented’
class NotImplemented : public std::logic_error
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/messageStream.H:225:27: error: expected unqualified-id before ‘__PRETTY_FUNCTION__’
#define FUNCTION_NAME __PRETTY_FUNCTION__
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:316:25: note: in definition of macro ‘FatalErrorIn’
::Foam::FatalError((functionName), __FILE__, __LINE__)
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:367:24: note: in expansion of macro ‘notImplemented’
#define NotImplemented notImplemented(FUNCTION_NAME)
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:367:39: note: in expansion of macro ‘FUNCTION_NAME’
#define NotImplemented notImplemented(FUNCTION_NAME)
^
/opt/intel_openvino/openvino/inference_engine/include/ie_common.h:210:7: note: in expansion of macro ‘NotImplemented’
class NotImplemented : public std::logic_error
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/messageStream.H:225:27: error: expected ‘)’ before ‘__PRETTY_FUNCTION__’
#define FUNCTION_NAME __PRETTY_FUNCTION__
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:316:25: note: in definition of macro ‘FatalErrorIn’
::Foam::FatalError((functionName), __FILE__, __LINE__)
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:367:24: note: in expansion of macro ‘notImplemented’
#define NotImplemented notImplemented(FUNCTION_NAME)
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:367:39: note: in expansion of macro ‘FUNCTION_NAME’
#define NotImplemented notImplemented(FUNCTION_NAME)
^
/opt/intel_openvino/openvino/inference_engine/include/ie_common.h:210:7: note: in expansion of macro ‘NotImplemented’
class NotImplemented : public std::logic_error
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/messageStream.H:225:27: error: expected ‘)’ before ‘__PRETTY_FUNCTION__’
#define FUNCTION_NAME __PRETTY_FUNCTION__
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:316:25: note: in definition of macro ‘FatalErrorIn’
::Foam::FatalError((functionName), __FILE__, __LINE__)
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:367:24: note: in expansion of macro ‘notImplemented’
#define NotImplemented notImplemented(FUNCTION_NAME)
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:367:39: note: in expansion of macro ‘FUNCTION_NAME’
#define NotImplemented notImplemented(FUNCTION_NAME)
^
/opt/intel_openvino/openvino/inference_engine/include/ie_common.h:210:7: note: in expansion of macro ‘NotImplemented’
class NotImplemented : public std::logic_error
^
In file included from /opt/intel_openvino/openvino/inference_engine/include/ie_blob.h:20:0,
from /opt/intel_openvino/openvino/inference_engine/include/inference_engine.hpp:16,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.H:68,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:31:
/opt/intel_openvino/openvino/inference_engine/include/ie_common.h:210:22: error: expected unqualified-id before ‘:’ token
class NotImplemented : public std::logic_error
^
In file included from /opt/intel_openvino/openvino/inference_engine/include/inference_engine.hpp:16:0,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.H:68,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:31:
/opt/intel_openvino/openvino/inference_engine/include/ie_blob.h: In static member function ‘static size_t InferenceEngine::Blob::product(const SizeVector&)’:
/opt/intel_openvino/openvino/inference_engine/include/ie_blob.h:245:75: warning: use of old-style cast [-Wold-style-cast]
return std::accumulate(std::begin(dims), std::end(dims), (size_t) 1, std::multiplies<size_t>());
^
In file included from /opt/intel_openvino/openvino/inference_engine/include/inference_engine.hpp:18:0,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.H:68,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:31:
/opt/intel_openvino/openvino/inference_engine/include/ie_error.hpp: At global scope:
/opt/intel_openvino/openvino/inference_engine/include/ie_error.hpp:16:7: warning: ‘class InferenceEngine::IErrorListener’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
class IErrorListener {
^
In file included from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/VectorSpaceI.H:26:0,
from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/VectorSpace.H:230,
from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/Vector.H:44,
from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/vector.H:39,
from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/fieldTypes.H:35,
from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/primitiveFieldsFwd.H:36,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.H:44,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:31:
/opt/intel_openvino/openvino/inference_engine/include/details/ie_exception_conversion.hpp: In function ‘void InferenceEngine::details::extract_exception(InferenceEngine::StatusCode, char*)’:
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:359:47: error: ‘FatalError’ was not declared in this scope
<< "Not implemented" << ::Foam::abort(FatalError);
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:367:24: note: in expansion of macro ‘notImplemented’
#define NotImplemented notImplemented(FUNCTION_NAME)
^
/opt/intel_openvino/openvino/inference_engine/include/details/ie_exception_conversion.hpp:60:36: note: in expansion of macro ‘NotImplemented’
case NOT_IMPLEMENTED:throw NotImplemented(msg);
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:359:47: note: suggested alternative:
<< "Not implemented" << ::Foam::abort(FatalError);
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:367:24: note: in expansion of macro ‘notImplemented’
#define NotImplemented notImplemented(FUNCTION_NAME)
^
/opt/intel_openvino/openvino/inference_engine/include/details/ie_exception_conversion.hpp:60:36: note: in expansion of macro ‘NotImplemented’
case NOT_IMPLEMENTED:throw NotImplemented(msg);
^
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:303:16: note: ‘Foam::FatalError’
extern error FatalError;
^
In file included from /opt/intel_openvino/openvino/inference_engine/include/cpp/ie_plugin_cpp.hpp:16:0,
from /opt/intel_openvino/openvino/inference_engine/include/ie_plugin_dispatcher.hpp:14,
from /opt/intel_openvino/openvino/inference_engine/include/inference_engine.hpp:21,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.H:68,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:31:
/opt/intel_openvino/openvino/inference_engine/include/details/ie_exception_conversion.hpp:60:55: warning: statement has no effect [-Wunused-value]
case NOT_IMPLEMENTED:throw NotImplemented(msg);
^
In file included from /opt/intel_openvino/openvino/inference_engine/include/inference_engine.hpp:21:0,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.H:68,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:31:
/opt/intel_openvino/openvino/inference_engine/include/ie_plugin_dispatcher.hpp: At global scope:
/opt/intel_openvino/openvino/inference_engine/include/ie_plugin_dispatcher.hpp:20:7: warning: ‘class InferenceEngine::PluginDispatcher’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
class PluginDispatcher {
^
In file included from tabulatedCombustionModel/FPVANNModel/FPVANNModel.H:68:0,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:31:
/opt/intel_openvino/openvino/inference_engine/include/inference_engine.hpp: In function ‘void InferenceEngine::TopResults(unsigned int, InferenceEngine::TBlob<T>&, std::vector<unsigned int>&)’:
/opt/intel_openvino/openvino/inference_engine/include/inference_engine.hpp:45:57: warning: use of old-style cast [-Wold-style-cast]
n = static_cast<unsigned>(std::min<size_t>((size_t) n, input.size()));
^
tabulatedCombustionModel/FPVANNModel/FPVANNModel.C: In member function ‘virtual void Foam::combustionModels::FPVANNModel::correctTabulatedANNTransport()’:
tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:371:17: warning: unused variable ‘celli_count’ [-Wunused-variable]
int celli_count = 0;
^
tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:404:17: warning: unused variable ‘patch_count’ [-Wunused-variable]
int patch_count = 0;
^
tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:301:16: warning: unused variable ‘Zeta’ [-Wunused-variable]
double Zeta;
^
tabulatedCombustionModel/FPVANNModel/FPVANNModel.C: In member function ‘virtual void Foam::combustionModels::FPVANNModel::correctCalculatedANNTransport()’:
tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:605:26: warning: unused variable ‘success’ [-Wunused-variable]
bool success = inf->doInference(frozenGraphName,inputOperationName,outputOperationName,no_of_inputs,no_of_outputs,input_dimensions,output_dimensions,cellsAndPatches,input_f_zeta_PVNorm,output_real,limit_intra,limit_inter,xlaJit);
^
tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:696:17: warning: unused variable ‘celli_count’ [-Wunused-variable]
int celli_count = 0;
^
tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:721:17: warning: unused variable ‘patch_count’ [-Wunused-variable]
int patch_count = 0;
^
In file included from tabulatedCombustionModel/FPVANNModel/FPVANNModel.H:66:0,
from tabulatedCombustionModel/FPVANNModel/FPVANNModel.C:31:
/home/elias/OpenFOAM/elias-4.1/LRT10Foam/src/../ThirdParty/ANNInference/TensorflowCAPI/inferenceC.H: At global scope:
/home/elias/OpenFOAM/elias-4.1/LRT10Foam/src/../ThirdParty/ANNInference/TensorflowCAPI/inferenceC.H:25:19: warning: ‘TF_Buffer* ReadBufferFromFile(const char*)’ defined but not used [-Wunused-function]
static TF_Buffer* ReadBufferFromFile(const char* file)
^
/home/elias/OpenFOAM/elias-4.1/LRT10Foam/src/../ThirdParty/ANNInference/TensorflowCAPI/inferenceC.H:55:13: warning: ‘void DeallocateTensor(void*, std::size_t, void*)’ defined but not used [-Wunused-function]
static void DeallocateTensor(void* data, std::size_t, void*) // vorher void* arg
^
make: *** [Make/linux64GccDPInt64Opt/tabulatedCombustionModel/FPVANNModel/FPVANNModel.o] Error 1
I did not change anything apart from including the additional header, and the error messages are totally weird. One colleauge mentioned that there might be some "conflict" between the two programs involved (OpenFOAM and OpenVINO). Can somebody give me a hint what the problem might be?
Thanks!
Edit: Maybe I should point out to these two sections:
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:316:13: error: ‘FatalError’ in namespace ‘Foam’ does not name a type
::Foam::FatalError((functionName), __FILE__, __LINE__)
/opt/intel_openvino/openvino/inference_engine/include/details/ie_exception_conversion.hpp: In function ‘void InferenceEngine::details::extract_exception(InferenceEngine::StatusCode, char*)’:
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:359:47: error: ‘FatalError’ was not declared in this scope
<< "Not implemented" << ::Foam::abort(FatalError);
The cause is buried around halfway your error dump:
#define NotImplemented notImplemented(FUNCTION_NAME)
OpenFOAM uses this as a macro to raise an error in unimplemented methods, while OpenVINO happens to define a class with the same name. C++ namespaces are only resolved after macro expansion, so that cannot help you.
Your options, in rough order of preference:
Include the OpenVINO headers first, then the OpenFOAM headers. This does mean you have to #undef NotImplemented if you also want to throw or catch these exceptions.
Include the OpenFOAM headers first, then #undef NotImplemented, and include the OpenVINO headers. This means you cannot use the OpenFOAM macro for your own purposes (although you probably do not need to).
Remove the macro from the OpenFOAM headers, if no other headers use it.

GLM: Can't compile anymore

Does anybody use this library anymore?
Worked great for me last year but now my code isn't compiling:
(on MinGW with GCC 4.6.1):
In file included from ../include/glm/./core/func_packing.hpp:190:0,
from ../include/glm/glm.hpp:103,
from SmoothRenderer.cpp:11:
../include/glm/./core/func_packing.inl: In function 'glm::detail::uint32 glm::packUnorm4x8(const glm::detail::tvec4<float>&)':
../include/glm/./core/func_packing.inl:84:17: error: expected primary-expression before '(' token
../include/glm/./core/func_packing.inl:84:17: error: expected primary-expression before ')' token
../include/glm/./core/func_packing.inl:84:17: error: expected ';' before 'round'
../include/glm/./core/func_packing.inl:85:26: error: 'D' was not declared in this scope
../include/glm/./core/func_packing.inl: In function 'glm::detail::tvec4<float> glm::unpackUnorm4x8(const uint32&)':
../include/glm/./core/func_packing.inl:94:38: warning: statement has no effect [-Wunused-value]
../include/glm/./core/func_packing.inl:99:4: error: 'D' was not declared in this scope
This is with newest version 0.9.4.3.
Similar problems on my Mac with latest clang:
In file included from SmoothRenderer.cpp:10:
In file included from ../include/glm/glm.hpp:103:
In file included from ../include/glm/./core/func_packing.hpp:190:
../include/glm/core/func_packing.inl:84:33: error: expected '(' for function-style cast or type construction
detail::uint8 D((detail::uint8)round(clamp(v.w, 0.0f, 1.0f) * 255.0f));
~~~~~~~~~~~~~^
./util.h:330:15: note: expanded from macro 'D'
# define D(x) x
^
In file included from SmoothRenderer.cpp:10:
In file included from ../include/glm/glm.hpp:103:
In file included from ../include/glm/./core/func_packing.hpp:190:
../include/glm/core/func_packing.inl:85:26: error: use of undeclared identifier 'D'
return detail::uint32((D << 24) | (C << 16) | (B << 8) | A);
^
../include/glm/core/func_packing.inl:99:4: error: use of undeclared identifier 'D'
D * 1.0f / 255.0f);
^
../include/glm/core/func_packing.inl:94:30: warning: expression result unused [-Wunused-value]
detail::uint32 D((p >> 24) & Mask8);
~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~
./util.h:330:15: note: expanded from macro 'D'
# define D(x) x
^
In file included from SmoothRenderer.cpp:10:
In file included from ../include/glm/glm.hpp:108:
In file included from ../include/glm/./core/func_noise.hpp:85:
../include/glm/core/func_noise.inl:125:33: error: too many arguments provided to function-like macro invocation
detail::tvec4<T> const D(0.0, 0.5, 1.0, 2.0);
^
../include/glm/core/func_noise.inl:125:27: error: expected ';' at end of declaration
detail::tvec4<T> const D(0.0, 0.5, 1.0, 2.0);
^
;
This is a header-only library. Things like this shouldn't be happening...
I am only using this for some 4x4 matrix multiplication and inversion. Since the rest of my app uses LAPACK extensively there is nothing i really need that glm does. But I hate when my code which I try to make very portable randomly breaks like this.
Yeah it turned out to be an issue with the D macro. Damn it, answering my question 4 minutes after asking it. That's the beauty of explaining a problem. Half the time that's enough.
This is one more reason to avoid using the preprocessor. Mad errors. Though, to its credit, clang was nice enough to not only mention that something seemed iffy with a macro defined elsewhere, it even copied it in there to show me.

MYSQL headers conflict with STL <algorithm> in C++

// File test.cpp
#include <my_global.h>
#include <algorithm>
int main()
{
return 0;
}
Compiled with: g++ -c -I /usr/local/mysql/include/mysql/ test.cpp, where /usr/local/mysql is the mysql install directory.Then the compiler report the following errors:
In file included from /usr/include/c++/4.4/algorithm:61,
from test.cpp:3:
/usr/include/c++/4.4/bits/stl_algobase.h:232:56: error: macro "min" passed 3 arguments, but takes just 2
/usr/include/c++/4.4/bits/stl_algobase.h:253:56: error: macro "max" passed 3 arguments, but takes just 2
In file included from /usr/include/c++/4.4/bits/stl_algo.h:61,
from /usr/include/c++/4.4/algorithm:62,
from test.cpp:3:
/usr/include/c++/4.4/bits/algorithmfwd.h:353:41: error: macro "max" passed 3 arguments, but takes just 2
/usr/include/c++/4.4/bits/algorithmfwd.h:364:41: error: macro "min" passed 3 arguments, but takes just 2
In file included from /usr/include/c++/4.4/algorithm:61,
from test.cpp:3:
/usr/include/c++/4.4/bits/stl_algobase.h:186: error: expected unqualified-id before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:186: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:186: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:186: error: expected initializer before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:209: error: expected unqualified-id before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:209: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:209: error: expected ‘)’ before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:209: error: expected initializer before ‘const’
/usr/include/c++/4.4/bits/stl_algobase.h:232: error: ‘std::min’ declared as an ‘inline’ variable
/usr/include/c++/4.4/bits/stl_algobase.h:232: error: template declaration of ‘const _Tp& std::min’
/usr/include/c++/4.4/bits/stl_algobase.h:235: error: expected primary-expression before ‘if’
/usr/include/c++/4.4/bits/stl_algobase.h:235: error: expected ‘}’ before ‘if’
/usr/include/c++/4.4/bits/stl_algobase.h:237: error: expected unqualified-id before ‘return’
/usr/include/c++/4.4/bits/stl_algobase.h:253: error: ‘max’ declared as an ‘inline’ variable
/usr/include/c++/4.4/bits/stl_algobase.h:253: error: template declaration of ‘const _Tp& max’
/usr/include/c++/4.4/bits/stl_algobase.h:256: error: expected primary-expression before ‘if’
/usr/include/c++/4.4/bits/stl_algobase.h:256: error: expected ‘}’ before ‘if’
/usr/include/c++/4.4/bits/stl_algobase.h:258: error: expected unqualified-id before ‘return’
/usr/include/c++/4.4/bits/stl_algobase.h:259: error: expected declaration before ‘}’ token
I think that there's some name conflict between my_global.h and algorithm, so I wrap my_global.h in a namespace:
// File test.cpp
namespace MYSQL_NAMESPACE {
#include <my_global.h>
}
#include <algorithm>
int main()
{
return 0;
}
But it doesn't help, the compiler still report the same errors. Then I change the include order as following:
// File test.cpp
#include <algorithm>
#include <my_global.h>
int main()
{
return 0;
}
Every thing goes well now.
Does Anybody Really Know What The Problem It Is?
TKS!
It seems that the mysql header defines a macro min.
#if !defined(max)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
This has been reported to MySQL as bug 28184. The bug is marked as closed, so try updating to the newest version. According to the bug page it should be fixed in version 5.1.23, version 6.0.4 and newer versions.
Apparently the namespace trick does not work because min/max are macros and the preprocessor does not look at namespace scope.
This might fix the problem:
#include <my_global.h>
#undef min
#undef max
#include <algorithm>
The whole thing looks horrible though :)
It looks like my_global.h defines some name used by algorithm as a preprocessor macro, causing compilation to fail. With the ordering that works, you won't be able to use whatever it is that my_global.h clobbers, but your code will at least compile unless you need that feature. Since preprocessor macros are not namespaced, the namespace wrapping will not help, as you have observed.
Therefore, it sounds like my_global.h is broken, but if everything works just use the include order that works and go with it. That's my preferred include order anyway - standard library headers first, followed by external library headers, followed by internal headers.