[ENet-discuss] Enet in C++

Bjørn Lindeijer bjorn at lindeijer.nl
Tue Jul 15 15:22:23 PDT 2008


(warning: old cow from over a month ago)

Hello Robbie,

Note that since you're having a compilation error on line 1 of your
little program (the iostream inlude), this problem is not related to
ENet, but it rather means your compiler setup is broken.

If you fix that, further things to note:

* It is probably better to include ENet like <enet/enet.h> instead of
<enet.h>, so that you don't need to add the include/enet directory
itself to your include path.

* You do not need to wrap the enet.h include in an extern "C" section,
since the header does this automatically when included in a C++
program.

Regards,
Bjørn

On 6/13/08, Robbie Diaz <metaldrummer610 at yahoo.com> wrote:
>
> Hi guys,
> I'm trying to use Enet in a C++ project for school and it won't compile at
> all. I keep getting these weird errors that are preventing the project from
> being built. I'm compiling my code with "g++ -I/usr/local/include/enet
> client.cpp -lenet"
>
> Here's my source,
>
> #include <iostream>
>
> extern "C" {
>      #include <enet.h>
> }
>
> using namespace std;
>
> int main()
> {
>     enet_initialize();
>     cout << "Hello World" << endl;
>     enet_deinitialize();
>     return 0;
> }
>
>
> And here's my error,
>
> In file included from /usr/include/c++/4.2/cwchar:52,
>                  from
> /usr/include/c++/4.2/bits/postypes.h:46,
>                  from /usr/include/c++/4.2/iosfwd:49,
>                  from /usr/include/c++/4.2/ios:43,
>                  from /usr/include/c++/4.2/ostream:45,
>                  from /usr/include/c++/4.2/iostream:45,
>                  from client.cpp:1:
> /usr/include/c++/4.2/ctime:66: error: '::clock_t' has not been declared
> /usr/include/c++/4.2/ctime:67: error: '::time_t' has not been declared
> /usr/include/c++/4.2/ctime:68: error: '::tm' has not been declared
> /usr/include/c++/4.2/ctime:70: error: '::clock' has not been declared
> /usr/include/c++/4.2/ctime:71: error: '::difftime' has not been declared
> /usr/include/c++/4.2/ctime:72: error: '::mktime' has not been declared
> /usr/include/c++/4.2/ctime:73: error: '::time' has not been declared
> /usr/include/c++/4.2/ctime:74: error: '::asctime' has not been declared
> /usr/include/c++/4.2/ctime:75: error: '::ctime' has not been declared
> /usr/include/c++/4.2/ctime:76: error: '::gmtime' has not been declared
> /usr/include/c++/4.2/ctime:77: error: '::localtime' has not been declared
> /usr/include/c++/4.2/ctime:78: error: '::strftime' has not been declared
> In file included from /usr/include/c++/4.2/locale:46,
>                  from
> /usr/include/c++/4.2/bits/ostream.tcc:46,
>                  from /usr/include/c++/4.2/ostream:572,
>                  from /usr/include/c++/4.2/iostream:45,
>                  from client.cpp:1:
> /usr/include/c++/4.2/bits/locale_facets.tcc: In member
> function '_InIter std::time_get<_CharT,
> _InIter>::_M_extract_via_format(_InIter, _InIter,
> std::ios_base&, std::_Ios_Iostate&, tm*, const _CharT*) const':
> /usr/include/c++/4.2/bits/locale_facets.tcc:1841: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1848: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1856: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1863: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1875: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1882: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1885: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1897: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1902: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1910: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1914: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1934: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1970: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc:1978: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc: In member
> function 'virtual _InIter std::time_get<_CharT,
> _InIter>::do_get_weekday(_InIter, _InIter, std::ios_base&,
> std::_Ios_Iostate&, tm*) const':
> /usr/include/c++/4.2/bits/locale_facets.tcc:2212: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc: In member
> function 'virtual _InIter std::time_get<_CharT,
> _InIter>::do_get_monthname(_InIter, _InIter,
> std::ios_base&, std::_Ios_Iostate&, tm*) const':
> /usr/include/c++/4.2/bits/locale_facets.tcc:2261: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
> /usr/include/c++/4.2/bits/locale_facets.tcc: In member
> function 'virtual _InIter std::time_get<_CharT,
> _InIter>::do_get_year(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&,
> tm*) const':
> /usr/include/c++/4.2/bits/locale_facets.tcc:2290: error:
> invalid use of incomplete type 'struct tm'
> /usr/include/wchar.h:129: error: forward declaration of 'struct tm'
>
>
> Thanks alot,
> Robbie


More information about the ENet-discuss mailing list