For some odd reason I recieve unknown type name for a typedef void variable located in a header file. Naturally i searched around the net and while it can be noted that I found similar issues it should also be noted that I am not using an IDE only Vim and Clang and don't have precompiled headers. In a separate test for the ctrie_int header, everything compiles but when I extend the implementation adding its header to the implementation file of another header I get the weird error seen below. I'm sure its a simple issue but i'm not sure what it is, any suggestions?
clang++ -Wall -Wextra -g -std=c++11 lzwtest.cpp -o lzwtest dict;
Project Compilation
.
.
.
.
.
Compiling CPP file lzwtest.cpp ...
In file included from lzwtest.cpp:2:
In file included from ./LZW.h:23:
In file included from ./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 return object of type 'int *' with an 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 is the header for the file being included
ctrie_int.h
#ifndef COM_WORDGAME_UTILITY_CTRIE_H
#define COM_WORDGAME_UTILITY_CTRIE_H
#ifdef __cplusplus
extern "C"{ //this is used to identify following code as C specific code which will enforce C style name mangling
#endif
//Declare a new void Type To Emulate C class
typedef void Trie_Int;
...Removed in attempt to shorten Question
#ifdef __cplusplus
}
#endif
#endif
This file uses the previous but even simple code or just the inclusion of the header file of the last causes the error described in the beginning
#ifndef COM_WORDGAME_UTILITY_CTRIE_H
#define COM_WORDGAME_UTILITY_CTRIE_H
#ifdef __cplusplus
extern "C"{ //this is used to identify following code as C specific code which will enforce C style name mangling
#endif
void compress(char src[],char dst[]);
void decompress(char src[],char dst[]);
#ifdef __cplusplus
}
#endif
#endif
//BELOW CODE WILL BE ADDED IN ANOTHER FILE
#include <stdio.h>
#include <stdlib.h>
#include "ctrie_int.h" // This causes an issue cannot find Trie_Int the functions return an odd message describing the Trie_Int was defered to an actual pointer integer
for clarity the first few lines of ctrie.ii looks like this
//#include "ctrie_int.h" //Should not be included would create cycle since ctrie_int.h declares it at the final line
#include "Trie.hpp" //C++ code
//THIS HAS TO BE COMPILED WITH C++ COMPILER TO BE COMPILED PROPERLY ANYWAY GAURDS UNEEDED
extern "C"{
//Create new Trie_Int Object
Trie_Int * newTrie_Int(int defVal){return new Trie<int>(defVal);}
....Removed In Attempt to shorten question
}
The clue is in the first stages of the error message:
Compiling CPP file lzwtest.cpp ...
In file included from lzwtest.cpp:2:
In file included from ./LZW.h:23:
In file included from ./ctrie_int.h:36: <<< Here
./ctrie_int.ii:7:1: error: unknown type name 'Trie_Int'
It appears that the file ctrie_int.ii is being included from your header before Trie_Int has been defined.
Related
So, I'm attempting to fork some open source code and upon compilation I am greeted with these errors:
C2039 'TransactionId': is not a member of 'CryptoNote'
C2061 syntax error: identifier 'TransactionId'
I'm relatively inexperienced with C++ usually confining myself to the realms of C#, however, I can clearly see that TransactionId is a typedef declared in a different file like so:
namespace CryptoNote {
typedef size_t TransactionId;
typedef size_t TransferId;
//more code
And the line throwing the error is:
void sendTransactionCompleted(CryptoNote::TransactionId _id, bool _error, const QString& _error_text);
To my inexperienced eyes, that looks as though TransactionID is definitly a member of Cryptonote is it not?
Any ideas what's going on?
The repo is here: https://github.com/hughesjs/Incendium_GUI
And the necessary submodule is here: https://github.com/hughesjs/Incendium_Crypt
Those typedefs are defined in Incendium_Crypt/include/IWalletLegacy.h.
void sendTransactionCompleted(CryptoNote::TransactionId _id, bool _error, const QString& _error_text);`
is defined in Incendium_GUI/src/gui/SendFrame.h, which includes IWallet.h. However, IWallet.h does not in turn include IWalletLegacy.h. Hence, those typedefs are unknown to SendFrame.h.
It's difficult to say without seeing all the code but a few things come to mind:
Firstly is this the first error you get. Compilation errors with C++ tend to result in a bunch of secondary errors. For example the following results in a similar error to what you see but fails to compile because size_t has not been defined:
namespace CryptoNote {
typedef size_t TransactionId;
typedef size_t TransferId;
}
int main(void)
{
CryptoNote::TransactionId id;
return 0;
}
$ g++ -std=c++11 namespace.cxx -o namespace
namespace.cxx:4:9: error: ‘size_t’ does not name a type
typedef size_t TransactionId;
^~~~~~
namespace.cxx:5:9: error: ‘size_t’ does not name a type
typedef size_t TransferId;
^~~~~~
namespace.cxx: In function ‘int main()’:
namespace.cxx:11:17: error: ‘TransactionId’ is not a member of ‘CryptoNote’
CryptoNote::TransactionId id;
^~~~~~~~~~~~~
See http://www.cplusplus.com/reference/cstring/size_t/ for a list of headers that define size_t.
Is CryptoNote nested inside another namespace?
Is there another CryptoNote defined in the namespace your function is declared in?
Are these in the same header file? If not, is the header file where the namespace is defined included in the header file containing the function declaration?
System information
Have I written custom code: Custom project
OS Platform and Distribution: macOS Sierra (10.12.6)
TensorFlow installed from: Source
TensorFlow version: Git tagged at 1.3 and master at d27ed9c
Python version: Python 2.7.13 :: Anaconda 4.4.0
Bazel version: 0.5.3_1-homebrew
Protobuf version: 3.3.2-homebrew
CUDA/cuDNN version: N/A
GPU model and memory: N/A
Exact command to reproduce:
Problem description
I compiled TensorFlow source code for Python & C++ API bindings following the steps shown in http://www.blitzblit.com/2017/06/11/creating-tensorflow-c-headers-and-libraries/ (We have to take into account that this tutorial is not updated). After compiling the TF source code I include the TF library in the C++ project:
#include <tensorflow/core/public/session.h>
Finally, I compile the C++ project (Until here everything seems fine). Then, when I try to launch the C++ code I get the following message:
/Applications/CLion.app/Contents/bin/cmake/bin/cmake --build /Users/arcadillanzacarmona/Desktop/FaceSDK/ cmake-build-debug --target FaceSDK -- -j 2
[ 96%] Built target dlib
[ 96%] Building CXX object CMakeFiles/FaceSDK.dir/main.cpp.o
clang: warning: -lcurl: 'linker' input unused [-Wunused-command-line-argument]
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:328:33: error: expected a qualified name after 'typename'
template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:328:33: error: expected ',' or '>' in template-parameter-list
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:864:59: error: template argument for non-type template parameter must be an expression
typedef internal::RepeatedPtrOverPtrsIterator<Element*, void*>
^~~~~
/usr/local/include/google/protobuf/repeated_field.h:328:33: note: template parameter is declared here
template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:867:55: error: template argument for non-type template parameter must be an expression
const void* const>
^~~~~
/usr/local/include/google/protobuf/repeated_field.h:328:33: note: template parameter is declared here
template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:2258:38: error: expected a qualified name after 'typename'
template <typename Element, typename VoidPtr>
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:2258:38: error: expected ',' or '>' in template-parameter-list
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:2262:48: error: template argument for non-type template parameter must be an expression
typedef RepeatedPtrOverPtrsIterator<Element, VoidPtr> iterator;
^~~~~~~
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^~~~~~
/usr/local/include/google/protobuf/repeated_field.h:2258:38: note: template parameter is declared here
template <typename Element, typename VoidPtr>
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:2289:61: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator==(const iterator& x) const { return it_ == x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2290:61: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator!=(const iterator& x) const { return it_ != x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2293:59: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator<(const iterator& x) const { return it_ < x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2294:61: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator<=(const iterator& x) const { return it_ <= x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2295:59: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator>(const iterator& x) const { return it_ > x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2296:61: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator>=(const iterator& x) const { return it_ >= x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2324:70: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
difference_type operator-(const iterator& x) const { return it_ - x.it_; }
~^~~~
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:24:
In file included from /usr/local/include/tensorflow/core/framework/tensor.h:21:
In file included from /usr/local/include/tensorflow/core/framework/allocator.h:26:
In file included from /usr/local/include/tensorflow/core/framework/variant.h:30:
In file included from /usr/local/include/tensorflow/core/platform/mutex.h:31:
/usr/local/include/tensorflow/core/platform/default/mutex.h:25:10: fatal error: 'nsync_cv.h' file not found
#include "nsync_cv.h"
^
15 errors generated.
gmake[3]: *** [CMakeFiles/FaceSDK.dir/build.make:63: CMakeFiles/FaceSDK.dir/main.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:68: CMakeFiles/FaceSDK.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:80: CMakeFiles/FaceSDK.dir/rule] Error 2
gmake: *** [Makefile:118: FaceSDK] Error 2
Can anyone help me? Seems that the main problem is in the google/protobuf.
The problem is that gif_lib.h and that protobuf header file are incompatible. More specifically, the problem is that gif_lib.h uses the preprocessor to define a macro called VoidPtr, and then the protobuf header uses VoidPtr as an identifier. The fault firmly lays with gif_lib, not protobuf! Preprocessor macros, by convention, are usually uppercase, should include the library name, and should be avoided entirely if possible (in this case, wouldn't a typedef have done?).
Here are some possible workarounds:
Include the protobuf header (or something that includes it, like a TensorFlow header) before the gif_lib.h one (or, again, something that includes it).
After including gif_lib.h, write #undef VoidPtr on a separate line (but this might cause other mysterious problems, depending on how gif_lib.h is implemented.
Do not #include those both of those two headers from any one of your files; hide them behind your own interfaces.
File a bug with whoever wrote gif_lib and get them to stop using the proprocessor in such a dangerous way.
Use a better designed library in place of gif_lib.
I had the similar issue which is solved by changing compiler and using a different version of C++(i.e. from clang to g++-5, g++-7, etc.). I suggest that you can try to solve it in this way. Sorry for not able to give a direct solution.
For the error about nsync_cv, alc1218's solution on this post may help, which is changing the file mutex.h as follows:
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_PLATFORM_DEFAULT_MUTEX_H_
#define TENSORFLOW_PLATFORM_DEFAULT_MUTEX_H_
// IWYU pragma: private, include "third_party/tensorflow/core/platform/mutex.h"
// IWYU pragma: friend third_party/tensorflow/core/platform/mutex.h
#include <chrono>
#include <condition_variable>
#include <mutex>
#include "tensorflow/core/platform/thread_annotations.h"
namespace tensorflow {
#undef mutex_lock
enum LinkerInitialized { LINKER_INITIALIZED };
// A class that wraps around the std::mutex implementation, only adding an
// additional LinkerInitialized constructor interface.
class LOCKABLE mutex : public std::mutex {
public:
mutex() {}
// The default implementation of std::mutex is safe to use after the linker
// initializations
explicit mutex(LinkerInitialized x) {}
void lock() ACQUIRE() { std::mutex::lock(); }
bool try_lock() EXCLUSIVE_TRYLOCK_FUNCTION(true) {
return std::mutex::try_lock();
};
void unlock() RELEASE() { std::mutex::unlock(); }
};
class SCOPED_LOCKABLE mutex_lock : public std::unique_lock<std::mutex> {
public:
mutex_lock(class mutex& m) ACQUIRE(m) : std::unique_lock<std::mutex>(m) {}
mutex_lock(class mutex& m, std::try_to_lock_t t) ACQUIRE(m)
: std::unique_lock<std::mutex>(m, t) {}
mutex_lock(mutex_lock&& ml) noexcept
: std::unique_lock<std::mutex>(std::move(ml)) {}
~mutex_lock() RELEASE() {}
};
// Catch bug where variable name is omitted, e.g. mutex_lock (mu);
#define mutex_lock(x) static_assert(0, "mutex_lock_decl_missing_var_name");
using std::condition_variable;
inline ConditionResult WaitForMilliseconds(mutex_lock* mu,
condition_variable* cv, int64 ms) {
std::cv_status s = cv->wait_for(*mu, std::chrono::milliseconds(ms));
return (s == std::cv_status::timeout) ? kCond_Timeout : kCond_MaybeNotified;
}
} // namespace tensorflow
#endif // TENSORFLOW_PLATFORM_DEFAULT_MUTEX_H_
or simply find where your "nsync_cv" is and include the whole path.
I included “cuda_runtime.h” in my project. It then raises compilation error:
In file included from /usr/local/cuda/include/common_functions.h:235:0,
from /usr/local/cuda/include/cuda_runtime.h:116,
from /usr/local/include/caffe2/core/common_gpu.h:7,
from /home/vpe.cripac/projects/LaS-VPE-Platform/src/native/DeepMAR_deploy/src/DeepMARCaffe2Utils.cpp:8:
/usr/local/cuda/include/math_functions.h:9421:99: error: redeclaration ‘float std::tanh(float)’ differs in ‘constexpr’
extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ __CUDA_CONSTEXPR__ float __cdecl tanh(float);
In file included from /usr/local/cuda/include/math_functions.h:8809:0,
from /usr/local/cuda/include/common_functions.h:235,
from /usr/local/cuda/include/cuda_runtime.h:116,
from /usr/local/include/caffe2/core/common_gpu.h:7,
from /home/vpe.cripac/projects/LaS-VPE-Platform/src/native/DeepMAR_deploy/src/DeepMARCaffe2Utils.cpp:8:
/usr/include/c++/4.8.2/cmath:520:3: error: from previous declaration ‘constexpr float std::tanh(float)’
tanh(float __x)
This happens both on Ubuntu and CentOS 7, using GCC 4.8.5 or 5.3.1.
Should I include any other header or define any macro before “cuda_runtime.h”?
You should never import math_functions.h into plain host code, and with g++ 4.8.5, I get an #error generated from within the header file if I try to do so. If you import cuda_runtime.h into your host code correctly, it will never import math_functions.h incorrectly:
$ cat test_math.cpp
#include <iostream>
#include <cmath>
#ifdef __BREAK_ME__
#include <math_functions.h>
#else
#include <cuda_runtime.h>
#endif
int main()
{
const float val = 0.123456789f;
std::cout << "tanh(" << val << ")=" << std::tanh(val) << std::endl;
return 0;
}
$ g++ -I/opt/cuda-8.0/include test_math.cpp
$ g++ -I/opt/cuda-8.0/include -D__BREAK_ME__ test_math.cpp
In file included from /opt/cuda-8.0/include/math_functions.h:10055:0,
from test_math.cpp:5:
/opt/cuda-8.0/include/crt/func_macro.h:50:2: error: #error -- incorrect inclusion of a cudart header file
#error -- incorrect inclusion of a cudart header file
^
I tried to install the external library SVL, that is given in the link. I did make install and it seems now I can import it as given in documentation using #include <svl/some_header_files.h>
Now I want to run some of my program to test. But I am struggling with it. I did
g++ vertex.hh vertex.cc
the program I want to work and it gives out,
In file included from vertex.hh:9:
In file included from /usr/local/include/svl/Vec3.h:14:
/usr/local/include/svl/Vec2.h:25:10: error: unknown type name 'Real'
Vec2(Real x, Real y); // (x, y)
^
/usr/local/include/svl/Vec2.h:25:18: error: unknown type name 'Real'
Vec2(Real x, Real y); // (x, y)
^
/usr/local/include/svl/Vec2.h:27:10: error: unknown type name 'ZeroOrOne'
Vec2(ZeroOrOne k); // v[i] = vl_zero
^
/usr/local/include/svl/Vec2.h:28:10: error: unknown type name 'Axis'
Vec2(Axis k); // v[k] = 1
^
/usr/local/include/svl/Vec2.h:32:5: error: unknown type name 'Real'
Real &operator [] (Int i);
^
/usr/local/include/svl/Vec2.h:32:31: error: unknown type name 'Int'; did you mean 'int'?
Real &operator [] (Int i);
and more similar errors, which is then followed by
In file included from vertex.cc:10:
In file included from /usr/local/include/svl/Vec3.h:14:
/usr/local/include/svl/Vec2.h:25:10: error: unknown type name 'Real'
Vec2(Real x, Real y); // (x, y)
^
/usr/local/include/svl/Vec2.h:25:18: error: unknown type name 'Real'
Vec2(Real x, Real y); // (x, y)
^
/usr/local/include/svl/Vec2.h:27:10: error: unknown type name 'ZeroOrOne'
Vec2(ZeroOrOne k); // v[i] = vl_zero
^
and more similar errors,
and in the end,
/usr/local/include/svl/Vec2.h:69:27: error: unknown type name 'Int'; did you mean 'int'?
Vec2 &MakeUnit(Int i, Real k = vl_one); // I[i]
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Can you tell me what is going on here? How can i fix this?
Here is the link to the two files vertex.ccand vertex.hh
https://www.dropbox.com/sh/4cax5ftk2lssots/AAA62m2VnSZXqBfB65VfVqFTa?dl=0
New error using #include "svl/SVL.h"
In file included from vertex.hh:13:
./edge.hh:289:10: warning: unelaborated friend declaration is a C++11 extension; specify 'class' to befriend 'QuadEdge'
[-Wc++11-extensions]
friend QuadEdge;
^
class
1 warning generated.
In file included from vertex.cc:12:
In file included from ./cell.hh:9:
./edge.hh:289:10: warning: unelaborated friend declaration is a C++11 extension; specify 'class' to befriend 'QuadEdge'
[-Wc++11-extensions]
friend QuadEdge;
^
class
In file included from vertex.cc:12:
./cell.hh:293:10: warning: unelaborated friend declaration is a C++11 extension; specify 'class' to befriend 'CellVertexIterator'
[-Wc++11-extensions]
Why are you compiling vertex.hh? Why not just
g++ vertex.cc
Secondly, can you show us the contents of your header file and source file. Actually, the source file can probably be:
#include "vertex.hh"
int main() { return 0; }
and the header file:
#include "svl/SVL.h"
Secondly, when you say "#include " are you just including some of SVL internal headers? That may not work. http://www.cs.cmu.edu/~ajw/doc/svl.html says "for basic use, the only header file needed is svl/SVL.h".
I've got this class definition in a .h file, and the implementation in a .cpp file. When I try to compile this, the header file gives some errors and warnings:
/home/don/BerthaApex/apex/src/lib/apexmain/apexloader.h:6: error: variable 'APEX_EXPORT ApexLoader' has initializer but incomplete type
class APEX_EXPORT ApexLoader
^
/home/don/BerthaApex/apex/src/lib/apexmain/apexloader.h:6: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
/home/don/BerthaApex/apex/src/lib/apexmain/apexloader.h:9: error: expected primary-expression before 'public'
public:
The code in which this error occurs is:
#ifndef _APEXLOADER_H
#define _APEXLOADER_H
#include "global.h"
class APEX_EXPORT ApexLoader
{
public:
int Load( int argc, char *argv[]);
};
#endif
With the "class APEX_EXPORT ApexLoader" being the line with the error and the warning.
The APEX_EXPORT is defined in a header file that is included from this same file.
EDIT:
The APEX_EXPORT is defined in "global.h" as follows:
#ifdef APEX_MAKEDLL
#define APEX_EXPORT APEX_EXPORT_DECL
#else
#define APEX_EXPORT APEX_IMPORT_DECL
#endif
Does anyone know why these errors are there? And how can I get rid of them?
Thank you in advance!
Compiler: gcc 4.8.4
OS: Ubuntu 14.04
My psychic debugging skills tell me that APEX_EXPORT isn't #defined and thus the compiler thinks you're trying to declare a variable of that type.
If you think you've included all the right headers the best way to go is to just run the preprocessor on your source file and see what it generates (for example g++ -E).