I am trying to wrap the OME Files C++ (Windows VC14 64‑bit (VS2015)) library (http://www.openmicroscopy.org/ome-files/downloads/) with CppSharp. After following the Generating Bindings tutorial, I am running into parsing error(s) where it says I cannot use ‘throw’ with exceptions disabled. Research on the internet says that if I use -fexceptions
, it should enable exceptions. However, even adding the -fexceptions
argument, I am still getting the parsing errors.
OS: Windows 10, 64-Bit
Used headers
omefilesinOMETiffReader.h
omefilesoutOMETiffWriter.h
omefilesVariantPixelBuffer.h
Used settings
DriverOptions driverOptions = driver.Options;
Module module;
ParserOptions parserOptions = driver.ParserOptions;
driverOptions.GeneratorKind = GeneratorKind.CSharp;
parserOptions.AddArguments("-fexceptions");
parserOptions.EnableRTTI = true;
module = driverOptions.AddModule("OMEFiles");
module.IncludeDirs.Add(IncludeDirectory);
module.Headers.Add(@"omefilesinOMETiffReader.h");
module.Headers.Add(@"omefilesoutOMETiffWriter.h");
module.Headers.Add(@"omefilesVariantPixelBuffer.h");
module.LibraryDirs.Add(LibDirectory);
module.Libraries.Add(@"ome-files.lib");
Target: MSVC/
Other settings
Stack trace or incompilable generated code
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/files/MetadataMap.h(902,9): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/files/MetadataMap.h(924,9): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/common/log.h(98,31): error: no template named 'severity_logger_mt' in namespace 'boost::log::v2_st::sources'; did you mean 'severity_logger'?
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/files/FormatHandler.h(291,13): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/files/FormatHandler.h(297,13): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includexercesc/internal/XSerializeEngine.hpp(745,9): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includexercesc/util/regx/Token.hpp(219,5): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includexercesc/util/regx/Token.hpp(227,5): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includexercesc/util/regx/Token.hpp(232,5): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includexercesc/util/regx/Token.hpp(237,5): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includexercesc/util/regx/Token.hpp(242,5): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includexercesc/util/regx/Token.hpp(247,5): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includexercesc/util/regx/Token.hpp(252,5): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/files/FormatReader.h(128,11): error: cannot use 'try' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/files/detail/FormatReader.h(329,13): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/files/detail/FormatReader.h(346,13): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includexercesc/util/BaseRefVectorOf.c(68,9): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includexercesc/util/BaseRefVectorOf.c(68,9): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includexercesc/util/BaseRefVectorOf.c(145,9): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includexercesc/util/BaseRefVectorOf.c(145,9): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/common/xml/dom/Base.h(203,15): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/common/xml/dom/Base.h(203,15): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/common/xml/dom/Base.h(247,15): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/common/xml/dom/Base.h(247,15): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/common/xml/dom/Base.h(203,15): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/common/xml/dom/Base.h(247,15): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/common/xml/dom/Base.h(203,15): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/common/xml/dom/Base.h(247,15): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/common/xml/dom/Base.h(247,15): error: cannot use 'throw' with exceptions disabled
C:Users...DocumentsVisual Studio 2015ProjectsOMEome-files-bundle-0.5.0includeome/common/xml/dom/Base.h(247,15): error: cannot use 'throw' with exceptions disabled
I’m trying to change the compiler collection of a project which uses a lot of exceptions (try/catch blocks) from Microsoft Visual C++ to LLVM, but ran into compilation issues.
Used tool chain:
- Visual Studio 2015 Enterprise (MSVC 14)
- LLVM 3.7 Windows/x64
Here is some test source code:
#include <iostream>
int main()
{
try
{
throw 20;
}
catch (int e)
{
std::cout << "An exception occurred. Exception Nr. " << e << 'n';
}
return 0;
}
Compiling the code with the built-in Visual Studio compiler collection (v140), this are the command line results:
ClCompile:
C:Program Files (x86)Microsoft Visual Studio 14.0VCbinCL.exe
/c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D _MBCS /Gm /EHsc /RTC1 /MDd /GS /fp:precise
/Zc:wchar_t /Zc:forScope /Zc:inline /Fo "Debug\" /Fd"Debugvc140.pdb" /Gd /TP
/analyze- /errorReport:queue Main.cpp
Main.cpp
Link:
C:Program Files (x86)Microsoft Visual Studio 14.0VCbinlink.exe
/ERRORREPORT:QUEUE /OUT:"C:UsersjurochaDesktopClangExceptDebugClangExcept.exe"
/INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
/MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /Debug
/PDB:"C:UsersjurochaDesktopClangExceptDebugClangExcept.pdb" /TLBID:1
/DYNAMICBASE /NXCOMPAT
/IMPLIB:"C:UsersjurochaDesktopClangExceptDebugClangExcept.lib"
/MACHINE:X86 DebugMain.obj
Compilation succeeds.
Now, changing the compilers to LLVM (LLVM-vs2014):
ClCompile:
C:Program FilesLLVM3.7msbuild-binCL.exe
/c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D _MBCS /Gm /EHsc /RTC1 /MDd /GS /fp:precise
/Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\" /Fd"Debugvc140.pdb" /Gd /TP
/analyze- /errorReport:queue -m32 -fmsc-version=1900 Main.cpp
clang-cl.exe : warning : argument unused during compilation: '/ZI' [ClangExcept.vcxproj]
clang-cl.exe : warning : argument unused during compilation: '/Gm' [ClangExcept.vcxproj]
clang-cl.exe : warning : argument unused during compilation: '/GS' [ClangExcept.vcxproj]
Main.cpp(7,3): error : cannot use 'throw' with exceptions disabled [ClangExcept.vcxproj]
throw 20;
^
Main.cpp(5,2): error : cannot use 'try' with exceptions disabled [ClangExcept.vcxproj]
try
^
2 errors generated.
According to this document, http://clang.llvm.org/docs/MSVCCompatibility.html:
«Exceptions and SEH: Partial». But I can’t make enough sense of it.
Has anyone been able to achieve this?
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
I am trying to build a C++ OpenCV project with ARM compiler 6 in ARM development studio ide. I already, downloaded version 3.2.0 from the GitHub repository of OpenCV and built it for the MinGW compiler using CMake GUI in windows. When I configure my project to use MinGW, I can cross-compile my code an generate the axf file without any problem. However, when I use ARM compiler 6 I’m getting the build report attached below., my questions are, what can I do to resolve the reported errors ? Do I need to re-build the OpenCV library for ARM compiler 6? If so which generator and platform should I choose in CMake GUI?
0028.build_log.txt
17:22:07 **** Incremental Build of configuration Debug for project Stereo_Circular_Eclipse **** make all 'Building file: ../depth/depth.cpp' 'Invoking: Arm C++ Compiler 6' armclang.exe --target=aarch64-arm-none-eabi -I"C:openCVbuild_opencvinstallinclude" -xc++ -fno-exceptions -O0 -g -MD -MP -c -o "depth/depth.o" "../depth/depth.cpp" armclang: warning: Your license for feature ds_suite_eval will expire in 30 days [-Wlicense-management] armclang: warning: Your license for feature ds_compiler_eval20191 will expire in 30 days [-Wlicense-management] In file included from ../depth/depth.cpp:12: In file included from C:openCVbuild_opencvinstallincludeopencv2/opencv.hpp:62: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann.hpp:48: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/flann_base.hpp:40: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/params.h:33: C:openCVbuild_opencvinstallincludeopencv2/flann/any.h:268:42: error: cannot use 'throw' with exceptions disabled if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast(); ^ C:openCVbuild_opencvinstallincludeopencv2/flann/any.h:277:42: error: cannot use 'throw' with exceptions disabled if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast(); ^ In file included from ../depth/depth.cpp:12: In file included from C:openCVbuild_opencvinstallincludeopencv2/opencv.hpp:62: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann.hpp:48: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/flann_base.hpp:40: C:openCVbuild_opencvinstallincludeopencv2/flann/params.h:78:9: error: cannot use 'throw' with exceptions disabled throw FLANNException(cv::String("Missing parameter '")+name+cv::String("' in the parameters given")); ^ In file included from ../depth/depth.cpp:12: In file included from C:openCVbuild_opencvinstallincludeopencv2/opencv.hpp:62: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann.hpp:48: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/flann_base.hpp:41: C:openCVbuild_opencvinstallincludeopencv2/flann/saving.h:113:9: error: cannot use 'throw' with exceptions disabled throw FLANNException("Invalid index file, cannot read"); ^ C:openCVbuild_opencvinstallincludeopencv2/flann/saving.h:117:9: error: cannot use 'throw' with exceptions disabled throw FLANNException("Invalid index file, wrong signature"); ^ C:openCVbuild_opencvinstallincludeopencv2/flann/saving.h:151:9: error: cannot use 'throw' with exceptions disabled throw FLANNException("Cannot read from file"); ^ C:openCVbuild_opencvinstallincludeopencv2/flann/saving.h:160:9: error: cannot use 'throw' with exceptions disabled throw FLANNException("Cannot read from file"); ^ C:openCVbuild_opencvinstallincludeopencv2/flann/saving.h:165:9: error: cannot use 'throw' with exceptions disabled throw FLANNException("Cannot read from file"); ^ C:openCVbuild_opencvinstallincludeopencv2/flann/saving.h:176:9: error: cannot use 'throw' with exceptions disabled throw FLANNException("Cannot read from file"); ^ C:openCVbuild_opencvinstallincludeopencv2/flann/saving.h:181:9: error: cannot use 'throw' with exceptions disabled throw FLANNException("Cannot read from file"); ^ In file included from ../depth/depth.cpp:12: In file included from C:openCVbuild_opencvinstallincludeopencv2/opencv.hpp:62: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann.hpp:48: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/flann_base.hpp:43: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/all_indices.h:36: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/kdtree_index.h:46: C:openCVbuild_opencvinstallincludeopencv2/flann/random.h:110:14: warning: 'random_shuffle<std::__1::__wrap_iter<int *> >' is deprecated [-Wdeprecated-declarations] std::random_shuffle(vals_.begin(), vals_.end()); ^ E:Program FilesArmDevelopment Studio 2019.1swARMCompiler6.13bin..includelibcxxalgorithm:3067:1: note: 'random_shuffle<std::__1::__wrap_iter<int *> >' has been explicitly marked deprecated here _LIBCPP_DEPRECATED_IN_CXX14 void ^ E:Program FilesArmDevelopment Studio 2019.1swARMCompiler6.13bin..includelibcxx__config:979:39: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX14' # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED ^ E:Program FilesArmDevelopment Studio 2019.1swARMCompiler6.13bin..includelibcxx__config:962:48: note: expanded from macro '_LIBCPP_DEPRECATED' # define _LIBCPP_DEPRECATED __attribute__ ((deprecated)) ^ In file included from ../depth/depth.cpp:12: In file included from C:openCVbuild_opencvinstallincludeopencv2/opencv.hpp:62: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann.hpp:48: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/flann_base.hpp:43: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/all_indices.h:38: C:openCVbuild_opencvinstallincludeopencv2/flann/kmeans_index.h:372:13: error: cannot use 'throw' with exceptions disabled throw FLANNException("Unknown algorithm for choosing initial centers."); ^ C:openCVbuild_opencvinstallincludeopencv2/flann/kmeans_index.h:435:13: error: cannot use 'throw' with exceptions disabled throw FLANNException("Branching factor must be at least 2"); ^ C:openCVbuild_opencvinstallincludeopencv2/flann/kmeans_index.h:536:13: error: cannot use 'throw' with exceptions disabled throw FLANNException("Number of clusters must be at least 1"); ^ In file included from ../depth/depth.cpp:12: In file included from C:openCVbuild_opencvinstallincludeopencv2/opencv.hpp:62: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann.hpp:48: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/flann_base.hpp:43: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/all_indices.h:41: C:openCVbuild_opencvinstallincludeopencv2/flann/hierarchical_clustering_index.h:384:13: error: cannot use 'throw' with exceptions disabled throw FLANNException("Unknown algorithm for choosing initial centers."); ^ C:openCVbuild_opencvinstallincludeopencv2/flann/hierarchical_clustering_index.h:467:13: error: cannot use 'throw' with exceptions disabled throw FLANNException("Branching factor must be at least 2"); ^ In file included from ../depth/depth.cpp:12: In file included from C:openCVbuild_opencvinstallincludeopencv2/opencv.hpp:62: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann.hpp:48: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/flann_base.hpp:43: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/all_indices.h:42: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/lsh_index.h:49: C:openCVbuild_opencvinstallincludeopencv2/flann/lsh_table.h:353:10: warning: 'random_shuffle<std::__1::__wrap_iter<unsigned long *> >' is deprecated [-Wdeprecated-declarations] std::random_shuffle(indices.begin(), indices.end()); ^ E:Program FilesArmDevelopment Studio 2019.1swARMCompiler6.13bin..includelibcxxalgorithm:3067:1: note: 'random_shuffle<std::__1::__wrap_iter<unsigned long *> >' has been explicitly marked deprecated here _LIBCPP_DEPRECATED_IN_CXX14 void ^ E:Program FilesArmDevelopment Studio 2019.1swARMCompiler6.13bin..includelibcxx__config:979:39: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX14' # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED ^ E:Program FilesArmDevelopment Studio 2019.1swARMCompiler6.13bin..includelibcxx__config:962:48: note: expanded from macro '_LIBCPP_DEPRECATED' # define _LIBCPP_DEPRECATED __attribute__ ((deprecated)) ^ In file included from ../depth/depth.cpp:12: In file included from C:openCVbuild_opencvinstallincludeopencv2/opencv.hpp:62: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann.hpp:48: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/flann_base.hpp:43: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/all_indices.h:43: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/autotuned_index.h:36: C:openCVbuild_opencvinstallincludeopencv2/flann/index_testing.h:95:9: error: cannot use 'throw' with exceptions disabled throw FLANNException("Ground truth is not computed for as many neighbors as requested"); ^ In file included from ../depth/depth.cpp:12: In file included from C:openCVbuild_opencvinstallincludeopencv2/opencv.hpp:62: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann.hpp:48: In file included from C:openCVbuild_opencvinstallincludeopencv2/flann/flann_base.hpp:43: C:openCVbuild_opencvinstallincludeopencv2/flann/all_indices.h:83:13: error: cannot use 'throw' with exceptions disabled throw FLANNException("Unknown index type"); ^ C:openCVbuild_opencvinstallincludeopencv2/flann/all_indices.h:112:13: error: cannot use 'throw' with exceptions disabled throw FLANNException("Unknown index type"); ^ C:openCVbuild_opencvinstallincludeopencv2/flann/all_indices.h:138:13: error: cannot use 'throw' with exceptions disabled throw FLANNException("Unknown index type"); ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 2 warnings and 20 errors generated. make: *** [depth/subdir.mk:20: depth/depth.o] Error 1 17:22:11 Build Finished (took 4s.192ms)