Native Extension: cannot use 'throw' with exceptions disabled (SOLVED)


#1

Hi,

I’m trying to update my native extension Look like things have changed :slight_smile:

Having a “cannot use ‘throw’ with exceptions disabled” error. I try to add “-fexceptions”, “-fcxx-exceptions” flags but they are invalid. seems like bundling for Windows is works but not for mac or linux. Am I missing something?

Building on MacOS.

My ext.manifest

name: DAABBCC

platforms:

 x86_64-win32:
  context:
   use-clang: true
 x86-win32:
  context:
   use-clang: true
 
 x86_64-osx:
  context:
   flags:      ["-stdlib=libc++","-fexceptions"]
   libs:       ["c++"]

 x86_64-linux:
  context:
   flags:      ["-std=c++11","-fexceptions"]

Also there is an other error/warning which I don’t know what it is.
What is the DLIB_LOG_DOMAIN ?

15


#2

Ah! I find the DLIB_LOG_DOMAIN: https://www.defold.com/ref/dmLog/


#3

Well, in general game engines don’t use exceptions, and we’re not either. We use “-fno-exceptions” and “-fno-rtti”. These are part of the command line when building the extensions.

What do you need exceptions for in this case?

Yes, the DLIB_LOG_DOMAIN warning is annoying, and it should be fixed in the next release (1.2.137)


#4

I’m using this lib: https://github.com/lohedges/aabbcc/blob/master/src/AABB.cc
It has useful exceptions. It’s nice to have these exceptions when developing.
Is there any other way of doing this that you can suggest?

Thank you @Mathias_Westerdahl .


#5

Well, if it’s an actual programmer error, I would call assert().

If it’s a user defined error, I would check those much higher up in the code. E.g. in this case in the Lua bindings, and then return luaL_error(L, "msg")


#6

Thank you, I’ll keep in mind.
Also clang compiler is really fast for Windows build and my previous errors are gone. :tada: