CLion checks and extern declaration of a C++ class without default constructor -
i have working class, example:
// myclass.h class myclass { public: explicit myclass(unsigned char enablepin); void enable(bool enable); private: const unsigned char menabepin; };
// myclass.cpp #include "myclass.h" #include <gpio.h> myclass::myclass(unsigned char enablepin) : menabepin(enablepin) { } void myclass::enable(bool enable) { gpio_set(menabepin, static_cast<unsigned char>(enable ? 0 : 1)); }
then have in file extern
declaration of 1 instance of class:
// main.h extern myclass myclass;
and of course actual definition in 1 .cpp
file:
// main.cpp #include "main.h" #include <board.h> myclass myclass(board::pins::myclass_enable_pin); int main() { // ... myclass.enable(true); }
this compiles without warnings -wall -wextra
, works well.
however seems clion 2017.2.1 not extern
declaration , complains about:
and offers me these intention actions:
despite fact recognises declaration-definition shows red-green arrows go definition/declaration shortcut.
i turn off type of checks, belong useful set of type checks, function parameter count mismatch not want turn off.
have run same problem , found neat workaround?
wiki
Comments
Post a Comment