c++ - Unknown Typename when declared in header -
for odd reason recieve unknown type name typedef void variable located in header file. naturally searched around net , while can noted found similar issues should noted not using ide vim , clang , don't have precompiled headers. in separate test ctrie_int header, compiles when extend implementation adding header implementation file of header weird error seen below. i'm sure simple issue i'm not sure is, suggestions?
clang++ -wall -wextra -g -std=c++11 lzwtest.cpp -o lzwtest dict; project compilation . . . . . compiling cpp file lzwtest.cpp ... in file included lzwtest.cpp:2: in file included ./lzw.h:23: in file included ./ctrie_int.h:36: ./ctrie_int.ii:7:1: error: unknown type name 'trie_int' trie_int * newtrie_int(int defval){return new trie<int>(defval);} ^ ./ctrie_int.ii:7:43: error: cannot initialize homecoming object of type 'int *' rvalue of type 'trie<int> *' trie_int * newtrie_int(int defval){return new trie<int>(defval);} ^~~~~~~~~~~~~~~~~~~~~ ./ctrie_int.ii:9:21: error: unknown type name 'trie_int' void deletetrie_int(trie_int * trie){delete ((trie<int> *)trie);} ^ ./ctrie_int.ii:11:19: error: unknown type name 'trie_int' int trie_int_size(trie_int * t){return ((trie<int> *)t)->size();} ^ ./ctrie_int.ii:13:30: error: unknown type name 'trie_int' int trie_int_getdefaultvalue(trie_int * t){return ((trie<int> *)t)->getdefaultvalue();} ^ ./ctrie_int.ii:15:23: error: unknown type name 'trie_int' int trie_int_contains(trie_int * t,const char * key){return ((trie<int> *)t)->contains(key); } ^ ./ctrie_int.ii:17:18: error: unknown type name 'trie_int' int trie_int_get(trie_int * t,char * key){return ((trie<int> *)t)->get(key); } ^ ./ctrie_int.ii:19:19: error: unknown type name 'trie_int' void trie_int_put(trie_int * t,char * s,int val){ ((trie<int> *)t)->put(s,val);} ^ ./ctrie_int.ii:21:37: error: unknown type name 'trie_int' const char * trie_int_longestprefix(trie_int * t,char * s){return ((trie<int> *)t)->longestprefix(s).c_str();} ^ ./ctrie_int.ii:23:23: error: unknown type name 'trie_int' int trie_int_compress(trie_int * t){return ((trie<int> *)t)->compress();} ^ 10 errors generated.
below header file beingness included
ctrie_int.h
#ifndef com_wordgame_utility_ctrie_h #define com_wordgame_utility_ctrie_h #ifdef __cplusplus extern "c"{ //this used identify next code c specific code enforce c style name mangling #endif //declare new void type emulate c class typedef void trie_int; ...removed in effort shorten question #ifdef __cplusplus } #endif #endif
this file uses previous simple code or inclusion of header file of lastly causes error described in beginning
#ifndef com_wordgame_utility_ctrie_h #define com_wordgame_utility_ctrie_h #ifdef __cplusplus extern "c"{ //this used identify next code c specific code enforce c style name mangling #endif void compress(char src[],char dst[]); void decompress(char src[],char dst[]); #ifdef __cplusplus } #endif #endif //below code added in file #include <stdio.h> #include <stdlib.h> #include "ctrie_int.h" // causes issue cannot find trie_int functions homecoming odd message describing trie_int defered actual pointer integer
for clarity first few lines of ctrie.ii looks this
//#include "ctrie_int.h" //should not included create cycle since ctrie_int.h declares @ final line #include "trie.hpp" //c++ code //this has compiled c++ compiler compiled anyway gaurds uneeded extern "c"{ //create new trie_int object trie_int * newtrie_int(int defval){return new trie<int>(defval);} ....removed in effort shorten question }
the clue in first stages of error message:
compiling cpp file lzwtest.cpp ... in file included lzwtest.cpp:2: in file included ./lzw.h:23: in file included ./ctrie_int.h:36: <<< here ./ctrie_int.ii:7:1: error: unknown type name 'trie_int'
it appears file ctrie_int.ii
beingness included header before trie_int
has been defined.
c++ c typename
No comments:
Post a Comment