"nested name specifier" error
-
wrote on 27 Mar 2019, 14:27 last edited by
Hi all -
I'm using Creator on a project. (I can't build with it, because I don't have a cross compiler, but it's still the best editor and code browser I know of.) I'm getting some errors that I don't fully understand.
General-purpose header file:
extern "C" { class Worker; } struct Tasks { EventGroupHandle_t tasksInitEventGroup Worker *worker; ... }
Worker object:
#include "structs.h" #include "worker.h" using namespace std; extern "C" { Worker::Worker() { ...
I'm getting this error everywhere I reference the Worker class:
incomplete type 'Worker' named in nested name specifier
What might I be doing wrong?
Thanks...
-
Hi all -
I'm using Creator on a project. (I can't build with it, because I don't have a cross compiler, but it's still the best editor and code browser I know of.) I'm getting some errors that I don't fully understand.
General-purpose header file:
extern "C" { class Worker; } struct Tasks { EventGroupHandle_t tasksInitEventGroup Worker *worker; ... }
Worker object:
#include "structs.h" #include "worker.h" using namespace std; extern "C" { Worker::Worker() { ...
I'm getting this error everywhere I reference the Worker class:
incomplete type 'Worker' named in nested name specifier
What might I be doing wrong?
Thanks...
wrote on 27 Mar 2019, 14:33 last edited by JonB@mzimmers
Bearing in mind that I'm not a C++ expert...extern "C" { Worker::Worker()
how do you expect that to work in C (no classes, no
::
). Come to that:extern "C" { class Worker; }
what about that
class
in C?In some shape or form I think your C++ compiler is complaining when it meets
Worker
because it doesn't think it has met its forward declarationclass Worker;
, presumably because it doesn't work like that when it's insideextern "C"
.Have a read through https://stackoverflow.com/questions/52261768/extern-c-with-class-and-dll to see if I'm wrong (probably am), and whether instead you fall foul of one of the rules/restrictions there?
-
wrote on 27 Mar 2019, 14:45 last edited by
In all honesty, I don't remember why I did that. Removing them doesn't eliminate the error, though.
I was able to eliminate the error messages by changing my kit to one I hacked up for my target, but I'm still curious as to why this wouldn't work if I were doing a conventional (non-cross) build.
This would be a lot easier if I could just have a fake qmake for cross development. The docs refer to one, but no one seems to know what/where it is.
-
In all honesty, I don't remember why I did that. Removing them doesn't eliminate the error, though.
I was able to eliminate the error messages by changing my kit to one I hacked up for my target, but I'm still curious as to why this wouldn't work if I were doing a conventional (non-cross) build.
This would be a lot easier if I could just have a fake qmake for cross development. The docs refer to one, but no one seems to know what/where it is.
-
wrote on 27 Mar 2019, 15:42 last edited by
I'm using the xtensa-esp32-elf-g++.exe compiler. The program builds fine (just not from Creator).
-
I'm using the xtensa-esp32-elf-g++.exe compiler. The program builds fine (just not from Creator).
wrote on 27 Mar 2019, 15:48 last edited by@mzimmers I can't understand your code, I can't understand how this special gcc version can compile it.
It is not standard conform, take a look at https://isocpp.org/wiki/faq/mixing-c-and-cppThis could help you to made your code standard conform, and so it will compile with almost all c++ compilers... not just this special version of gcc.
-
I'm using the xtensa-esp32-elf-g++.exe compiler. The program builds fine (just not from Creator).
@mzimmers said in "nested name specifier" error:
The program builds fine (just not from Creator).
Probably a compiler idiosyncrasy. It should slap you for that code. You can't request C-linkage for methods, the compiler just can't generate code for that. Use
extern "C"
only for the free functions you don't want decorated (decorated here refers to symbol decoration for linkage). And don't forget the implications of using C-linkage, e.g. there's no overloading for undecorated symbols, meaning that the following:int a() {} int a(int) {}
is a symbol redefinition error at link time.
-
wrote on 27 Mar 2019, 18:56 last edited by
OK, thanks for the education...they're all removed and the warnings have disappeared.
-
This post is deleted!