root-project / cling

The cling C++ interpreter
Other
3.49k stars 270 forks source link

Language strict mode? #417

Open deliciouslytyped opened 3 years ago

deliciouslytyped commented 3 years ago

It's not clear to me from the little documentation I've looked at whether CLING supports a strict C (or C++, or otherwise) mode? The impression I got was that it supports some sort of mixed language - whereas it's often emphasized that C and C++ are not the same language.

(Context: I'm trying to learn C and I figured CLING might be a convenient environment for trying things.)

deliciouslytyped commented 3 years ago

Does passing -x c++ make sense? If I do it I get the following, and I'm not sure whether I need to file a bug report on NixOS:

$ cling -x c++
In file included from input_line_2:1:
/nix/store/p7pwn7a4kia9zrcxfaywv492cg8ryvzp-cling-unwrapped-0.7/include/cling/Interpreter/RuntimeUniverse.h:162:26: warning: default template arguments for a function template are a C++11 extension [-Wc++11-extensions]
      template <class T, class = T (*)() /*disable for arrays*/>
                         ^       ~~~~~~~
input_line_2:3:62: error: expected function body after function declarator
extern "C" int __cxa_atexit(void (*f)(void*), void*, void*)  noexcept;
                                                             ^
input_line_2:5:55: error: use of undeclared identifier '__cxa_atexit'
extern "C" int atexit(void(*f)())  throw ()  { return __cxa_atexit((void(*)(void*))f, 0, __dso_handle); }
                                                      ^

****************** CLING ******************
* Type C++ code and press enter to run it *
*             Type .q to exit             *
*******************************************
[cling]$ 
SimeonEhrig commented 3 years ago

-x c++ is set automatically. The only other valid option is -x cuda at the moment.

Does the error messages also appears, if you only runs cling?

deliciouslytyped commented 3 years ago

No errors if I only run cling.