C++ 是什么导致我的‘;法塔莱罗&x2019;在命名空间中‘;泡沫&x2019;不为类型命名";错误?

C++ 是什么导致我的‘;法塔莱罗&x2019;在命名空间中‘;泡沫&x2019;不为类型命名";错误?,c++,C++,我有一个奇怪的错误,我有一段时间没有解决。我想通过使用英特尔OpenVIO的推理引擎来扩展一个C++软件包。因此,我必须动态链接一些库,并在现有代码中包含一些头文件。以前,它编译时没有任何错误。然后我包括找到的第一个头文件(#include“inference_engine.hpp”),但是我得到了这个错误消息 In file included from /opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/VectorSpaceI.H:26:0,

我有一个奇怪的错误,我有一段时间没有解决。我想通过使用英特尔OpenVIO的推理引擎来扩展一个C++软件包。因此,我必须动态链接一些库,并在现有代码中包含一些头文件。以前,它编译时没有任何错误。然后我包括找到的第一个头文件(#include“inference_engine.hpp”),但是我得到了这个错误消息

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
/opt/intel\u openvino/openvino/interference\u engine/include/details/ie\u exception\u conversion.hpp:在函数“void推断引擎::详细信息::提取异常(推断引擎::状态代码,字符*)”中:
/opt/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/error.H:359:47:错误:未在此范围内声明“FatalError”

原因隐藏在错误转储的一半左右:

#define NotImplemented notImplemented(FUNCTION_NAME)
OpenFOAM将其用作宏,在未实现的方法中引发错误,而OpenVINO恰好定义了一个同名的类。C++命名空间只有在宏扩展后才能解决,所以不能帮助您。 您的选择,按照偏好的大致顺序:

  • 首先包括OpenVINO标头,然后是OpenFOAM标头。这意味着您必须
    #undef NotImplemented
    ,如果您还想抛出或捕获这些异常
  • 首先包括OpenFOAM头,然后是
    #undef NotImplemented
    ,并包括OpenVINO头。这意味着您不能出于自己的目的使用OpenFOAM宏(尽管您可能不需要)
  • 如果没有其他标头使用宏,请从OpenFOAM标头中删除宏

  • 有更多的选择,但相当昂贵。一般来说,将外部库包装到您自己的类包装器中是一种很好的习惯(它可以实现穷人的PIMPL,但可以防止任何此类问题)。OP的问题是一个很好的教训,为什么你永远不应该定义一个离开标题的宏。嗨@Botje(还有Radoslaw Cybulski)-我已经尝试了#1个建议,目前效果很好-错误消失了!我将尝试包含更多的标题以获得所有功能。非常感谢,我从来没有想过这是一个解决办法@tre95我必须打开泡沫。谢谢,不过他们可能已经修复了它,问题是我使用的是4.1版,因为我们研究所大规模扩展了这个版本,目前无法切换到更新的版本。
    /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);
    
    
    #define NotImplemented notImplemented(FUNCTION_NAME)