c++xcodevtk

Xcode 12 - Error when building .m file because of " Could not build module 'std' "


I'm facing a problem I wasn't able to resolve in days.

I want to include some VTK header within my .m file, which works up to the point where some further linked VTK-Headers within the one I included tries to do:

#include <fstream>

An error occurs saying

'fstream' file not found

After some googling I came across the solution to add the following to my 'Header Search Paths': "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/"

The file now seems to be found, but some new errors occurred.

Could not build module 'std'

Unknown typename 'namespace'

Unknown typename '_LIBCPP_BEGIN_NAMESPACE_STD'

Unknown typename '_LIBCPP_END_NAMESPACE_STD'

Expected ';' after top level declarator

etc.

These occur whithin __nullptr, cstddef, type_traits.

I also tried to change the "C++ Standard Library" from 'Compiler Default' to 'libc++' or 'libstdc++', but nothing worked.

Does anybody know how to resolve this?

Additional Information:


Solution

  • As already mentioned, changing the file types from Objective-C (.m extension) to Objective-C++ (.mm extension) resolved the issue.