|
include header files in .cpp files and use forward declaration in .h files.
-Saurabh
|
|
|
|
|
Excuse me if I am a little confused, but I did not see a reference to T_UserThread() any where in SocketHandling.h.
If you must place the actual code for T_UserThread() in the header instead of a source code file, then you should mark it as inline. If you do not then you will get a whole lot of redefinition errors, because each source code file that includes the header will have its own copy of the function.
Another solution to such problems, at least when dealing with classes, is to use forward declarations. A forward declaration is sort of like a prototype, only for classes instead of functions.
If all else fails, then move the code for T_UserThread() into a source code file and just place a prototype in the SocketHandling.h header as well as the Globals.h header. I do not recommend this solution but it will work, you just have to make sure that both prototypes are well commented so that you know there are two of them.
Good Luck!
INTP
Every thing is relative...
|
|
|
|
|
Alright... I put a prototype at the beginning of SocketHandling.h for T_UserThread(...) , then I put the function in server.cpp and Globals.h, and now I get these errors:
Globals.h(30): error C2065: 'network' : undeclared identifier<br />
Globals.h(30): error C2065: 'network' : undeclared identifier<br />
Globals.h(30): error C2228: left of '.UserThread' must have class/struct/union type<br />
type is ''unknown-type''<br />
Globals.h(30): error C2228: left of '.UserThread' must have class/struct/union type<br />
type is ''unknown-type''<br />
server.cpp(48): error C2084: function 'int T_UserThread(void *)' already has a body<br />
server.cpp(50): error C2228: left of '.UserThread' must have class/struct/union type<br />
type is ''unknown-type''<br />
server.cpp(50): error C3861: 'network': identifier not found, even with argument-dependent lookup<br />
server.cpp(60): error C2228: left of '.Start' must have class/struct/union type<br />
type is ''unknown-type''<br />
server.cpp(60): error C3861: 'network': identifier not found, even with argument-dependent lookup<br />
server.cpp(75): error C2228: left of '.FindConnections' must have class/struct/union type<br />
type is ''unknown-type''<br />
server.cpp(75): error C3861: 'network': identifier not found, even with argument-dependent lookup<br />
SocketHandling.cpp(194): warning C4312: 'type cast' : conversion from 'long' to 'char *' of greater size<br />
SocketHandling.cpp(199): warning C4312: 'type cast' : conversion from 'long' to 'char *' of greater size<br />
SocketHandling.h(65): error C2371: 'network' : redefinition; different basic types<br />
SocketHandling.h(65): error C2371: 'network' : redefinition; different basic types
What am I doing wrong? Thanks!
BTW: I updated the files.
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
I am not sure exactly what you did, but I did forget to mention that you should not be declaring global variables in your header files. If you need a global variable like network, then you should declare it in one of your source files and then place the same statement in the globals header file [or some other header] with the prefix "extern".
Example:
// in sorce file
MyClass network;
// in header file
extern MyClass network.
As for error C2084, that is exactly why the function should be in a source file. It sound like you still have two copies of the same function, are you sure you replaced it with a prototype in the header. Because if you did not then this is exactly the type of error message you would get.
Most of the errors you seem to be getting stem from the first error. If you solve the first error then most of them will go away.
I can not go to your code link from within this page, but I will post an example of the T_UserThread() function written as an inline template. It will not help you solve your current poblem, but it will give you something else to think about as far as design is concerned. After all I believe most of your problems are the result of design issues.
INTP
Every thing is relative...
|
|
|
|
|
Template<class playertype=""> inline
int T_UserThread(PlayerType* np)
{
network.UserThread(*np);
}
// Or better yet
Template<class playertype=""> inline
int T_UserThread(PlayerType& np)
{
network.UserThread(np);
}
Both of these versions are called just like any other function, but they are type safe. That is the compiler check generates the proper function and checks the arguments at compile time. Of course I do not know why you where using a void pointer in the first place. You seemed to know what the type being passed was and therefore passing a void made no since.
Also why bother even creating the function T_UserThread() as all it needs to do is call network.UserThread(), and since network is already a global variable you can just make the call directly and it will still be clear what you are doing in your code.
INTP
Every thing is relative...
|
|
|
|
|
i read your code.
1)try to add declare:
int T_UserThread(void * np);
before
#include "SocketHandling.h"
in Globals.h
and do somethig similar to this for other files if neccessary.
2)u must add keyword
inline
for the function in Globals.h, this is syntax requires.
A special image tool for Windows C++ programmers, don't miss it!
The world unique Software Label Maker is waiting for you and me ...
A nice hyper tool for optimizing your Microsoft html-help contents.
|
|
|
|
|
I recommend you rethink the layout of your header files. Header files should never need to include each other.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
The problems he is having do stem for poor design and a lack of understanding some of the C/C++ basics. I have seen header files that include each other, a very bad idea, but they usualy solve the problems that presents with forward declarations and the like.
INTP
Every thing is relative...
|
|
|
|
|
John R. Shaw wrote: I have seen header files that include each other, a very bad idea, but they usualy solve the problems that presents with forward declarations and the like.
IMO, if header files need include each other, then their contents either belong together in the same header file, or need to be separated into more header files so you have more fine-grained control.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I agree with you one hundred percent! To be honest it has been some years since I have seen the subject come up. I can not even remember if I have ever made that mistake in design.
INTP
Every thing is relative...
|
|
|
|
|
John R. Shaw wrote: I can not even remember if I have ever made that mistake in design.
I have . I quickly rectified it once I realised I had though
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Seen a #include "stdafx.h" lately, and what stdafx.h contains?
What I DON'T like about that rule is, I locate a header file with a particular function, and I spend the next twenty mintues including about 20 more header files to resolve all the type definitions, data structures, base types and other crap required to use the function from the first header.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Sorry for the delay, I was entertaining myself with a Pokemon game...
Anyways... Yeah, now I'm getting an error saying that the network variable was already declared in server.obj... What?! It ain't on server.cpp... How can it be on the obj file? The only declaration I can find is this one:
} network; (after the class declaration)
Why is it already declared on server.obj? Dang... Thanks!
BTW: I have removed Globals.h, and there's no more includes depending on each other...
Maybe I am doing it right, but it's a problem with SDL or SDL_net?
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
-- modified at 21:18 Monday 10th April, 2006
|
|
|
|
|
If you declare a variable in a header file and include that header file into more than one source file, then you will get the 'already declared' types of errors and warnings.
It is best to ONLY define the variable in a single header file and declare an instance of the variable in a single source file.
For example, your header file 'SuperDuperClass.H' would have something like this in it:
// this is the instance definition, leting oter source files know there is
// a variable g_MySuperDuperClass of type SuperDuperClass out there somewhere
extern SuperDuperClass g_MySuperDuperClass;
And a single source file somewhere in your project would have this near the top:
#include "SuperDuperClass.H"
// this is the instance declaration
SuperDuperClass g_MySuperDuperClass;
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Yay, it worked!
But now I'm facing these, which where after the previous error:
server error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCD.lib(typinfo.obj)<br />
server error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCD.lib(typinfo.obj)
And then some redefinition errors of some standard functions:
server error LNK2005: _exit already defined in LIBCD.lib(crt0dat.obj)<br />
server error LNK2005: _strncpy already defined in LIBCD.lib(strncpy.obj)<br />
server error LNK2005: _fgetc already defined in LIBCD.lib(fgetc.obj)<br />
server error LNK2005: _fclose already defined in LIBCD.lib(fclose.obj)<br />
server error LNK2005: _setvbuf already defined in LIBCD.lib(setvbuf.obj)<br />
server error LNK2005: __isctype already defined in LIBCD.lib(isctype.obj)<br />
server warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
And then these:
server error LNK2001: unresolved external symbol "class SockHnd network" (?network@@3VSockHnd@@A)<br />
server error LNK2019: unresolved external symbol "class SockHnd network" (?network@@3VSockHnd@@A) referenced in function "public: bool __thiscall SockHnd::Start(int,int)" (?Start@SockHnd@@QAE_NHH@Z)
What's with the __thiscall and type_info stuff? I've never seen/used them before...
What might be the problem? Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
Go to the project settings, I think it is under a 'Link' tab, and find a checkbox labeled 'ignore default libraries' or something similar to that, and check it.
Then try your build again.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Dang, now I get MORE errors:
server error LNK2001: unresolved external symbol "class SockHnd network" (?network@@3VSockHnd@@A)<br />
server error LNK2019: unresolved external symbol "class SockHnd network" (?network@@3VSockHnd@@A) referenced in function "public: bool __thiscall SockHnd::Start(int,int)" (?Start@SockHnd@@QAE_NHH@Z)<br />
server error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > std::cout" (?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A)<br />
server error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > std::cout" (?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A)<br />
server error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function _SDL_main<br />
server error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function "public: bool __thiscall SockHnd::Start(int,int)" (?Start@SockHnd@@QAE_NHH@Z)<br />
server error LNK2001: unresolved external symbol __RTC_Shutdown<br />
server error LNK2001: unresolved external symbol __RTC_Shutdown<br />
server error LNK2001: unresolved external symbol __RTC_InitBase<br />
server error LNK2001: unresolved external symbol __RTC_InitBase<br />
server error LNK2019: unresolved external symbol ___CxxFrameHandler referenced in function __ehhandler$?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z<br />
server error LNK2001: unresolved external symbol ___CxxFrameHandler<br />
server error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8 referenced in function __catch$?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z$0<br />
server error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8 referenced in function "public: void __thiscall SockHnd::FindConnections(void)" (?FindConnections@SockHnd@@QAEXXZ)<br />
server error LNK2019: unresolved external symbol __except_list referenced in function "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::put(char)" (?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z)<br />
server error LNK2019: unresolved external symbol __except_list referenced in function "public: void __thiscall SockHnd::FindConnections(void)" (?FindConnections@SockHnd@@QAEXXZ)<br />
server error LNK2019: unresolved external symbol "public: void __thiscall std::ios_base::clear(int,bool)" (?clear@ios_base@std@@QAEXH_N@Z) referenced in function "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::clear(int,bool)" (?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z)<br />
server error LNK2001: unresolved external symbol "public: void __thiscall std::ios_base::clear(int,bool)" (?clear@ios_base@std@@QAEXH_N@Z)<br />
server error LNK2019: unresolved external symbol "bool __cdecl std::uncaught_exception(void)" (?uncaught_exception@std@@YA_NXZ) referenced in function "public: __thiscall std::basic_ostream<char,struct std::char_traits<char> >::sentry::~sentry(void)" (??1sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@XZ)<br />
server error LNK2019: unresolved external symbol "bool __cdecl std::uncaught_exception(void)" (?uncaught_exception@std@@YA_NXZ) referenced in function __catch$??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z$0<br />
server error LNK2019: unresolved external symbol _strlen referenced in function "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z)<br />
server error LNK2001: unresolved external symbol _strlen<br />
server error LNK2019: unresolved external symbol "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) referenced in function "public: bool __thiscall SockHnd::Start(int,int)" (?Start@SockHnd@@QAE_NHH@Z)<br />
server error LNK2019: unresolved external symbol __RTC_UninitUse referenced in function "public: int __thiscall SockHnd::UserThread(struct Player)" (?UserThread@SockHnd@@QAEHUPlayer@@@Z)<br />
server error LNK2019: unresolved external symbol _free referenced in function "void __cdecl std::_DebugHeapDelete<class std::locale::facet>(class std::locale::facet *)" (??$_DebugHeapDelete@Vfacet@locale@std@@@std@@YAXPAVfacet@locale@0@@Z)<br />
server error LNK2001: unresolved external symbol "public: __thiscall exception::exception(class exception const &)" (??0exception@@QAE@ABV0@@Z)<br />
server error LNK2001: unresolved external symbol "public: __thiscall bad_cast::bad_cast(class bad_cast const &)" (??0bad_cast@@QAE@ABV0@@Z)<br />
server error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)<br />
server error LNK2001: unresolved external symbol "public: virtual __thiscall bad_cast::~bad_cast(void)" (??1bad_cast@@UAE@XZ)<br />
server error LNK2019: unresolved external symbol "public: void __thiscall std::locale::facet::_Register(void)" (?_Register@facet@locale@std@@QAEXXZ) referenced in function "class std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > > const & __cdecl std::use_facet<class std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > > >(class std::locale const &)" (??$use_facet@V?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@@std@@YAABV?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@0@ABVlocale@0@@Z)<br />
server error LNK2019: unresolved external symbol "public: __thiscall bad_cast::bad_cast(char const *)" (??0bad_cast@@QAE@PBD@Z) referenced in function "class std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > > const & __cdecl std::use_facet<class std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > > >(class std::locale const &)" (??$use_facet@V?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@@std@@YAABV?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@0@ABVlocale@0@@Z)<br />
server error LNK2019: unresolved external symbol "public: class std::locale::facet const * __thiscall std::locale::_Getfacet(unsigned int)const " (?_Getfacet@locale@std@@QBEPBVfacet@12@I@Z) referenced in function "class std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > > const & __cdecl std::use_facet<class std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > > >(class std::locale const &)" (??$use_facet@V?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@@std@@YAABV?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@0@ABVlocale@0@@Z)<br />
server error LNK2019: unresolved external symbol __CxxThrowException@8 referenced in function "class std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > > const & __cdecl std::use_facet<class std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > > >(class std::locale const &)" (??$use_facet@V?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@@std@@YAABV?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@0@ABVlocale@0@@Z)<br />
server error LNK2001: unresolved external symbol "private: static int std::locale::id::_Id_cnt" (?_Id_cnt@id@locale@std@@0HA)<br />
server error LNK2019: unresolved external symbol "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z) referenced in function __unwindfunclet$?_Getcat@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@SAIPAPBVfacet@locale@2@@Z$0<br />
server error LNK2019: unresolved external symbol "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) referenced in function "public: static unsigned int __cdecl std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > >::_Getcat(class std::locale::facet const * *)" (?_Getcat@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@SAIPAPBVfacet@locale@2@@Z)<br />
server error LNK2001: unresolved external symbol "struct std::_DebugHeapTag_t const std::_DebugHeapTag" (?_DebugHeapTag@std@@3U_DebugHeapTag_t@1@B)<br />
server error LNK2019: unresolved external symbol "public: __thiscall std::_Locinfo::~_Locinfo(void)" (??1_Locinfo@std@@QAE@XZ) referenced in function "public: __thiscall std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > >::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > >(unsigned int)" (??0?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QAE@I@Z)<br />
server error LNK2019: unresolved external symbol "public: __thiscall std::_Locinfo::_Locinfo(char const *)" (??0_Locinfo@std@@QAE@PBD@Z) referenced in function "public: __thiscall std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > >::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > >(unsigned int)" (??0?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QAE@I@Z)<br />
server error LNK2019: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) referenced in function "public: virtual void * __thiscall std::locale::facet::`scalar deleting destructor'(unsigned int)" (??_Gfacet@locale@std@@UAEPAXI@Z)<br />
server error LNK2019: unresolved external symbol _memcpy referenced in function "public: static char * __cdecl std::char_traits<char>::copy(char *,char const *,unsigned int)" (?copy@?$char_traits@D@std@@SAPADPADPBDI@Z)<br />
server error LNK2019: unresolved external symbol _sprintf referenced in function "protected: virtual class std::ostreambuf_iterator<char,struct std::char_traits<char> > __thiscall std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > >::do_put(class std::ostreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,char,long)const " (?do_put@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$ostreambuf_iterator@DU?$char_traits@D@std@@@2@V32@AAVios_base@2@DJ@Z)<br />
server error LNK2001: unresolved external symbol __fltused<br />
server error LNK2019: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::assign(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int,unsigned int)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ABV12@II@Z)<br />
server error LNK2019: unresolved external symbol _memmove referenced in function "public: static char * __cdecl std::char_traits<char>::move(char *,char const *,unsigned int)" (?move@?$char_traits@D@std@@SAPADPADPBDI@Z)<br />
server error LNK2019: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ) referenced in function "protected: bool __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Grow(unsigned int,bool)" (?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAE_NI_N@Z)<br />
server error LNK2019: unresolved external symbol _strcspn referenced in function "private: class std::ostreambuf_iterator<char,struct std::char_traits<char> > __cdecl std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > >::_Fput(class std::ostreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,char,char const *,unsigned int,unsigned int,unsigned int,unsigned int)const " (?_Fput@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@ABA?AV?$ostreambuf_iterator@DU?$char_traits@D@std@@@2@V32@AAVios_base@2@DPBDIIII@Z)<br />
server error LNK2019: unresolved external symbol _memchr referenced in function "private: class std::ostreambuf_iterator<char,struct std::char_traits<char> > __cdecl std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > >::_Fput(class std::ostreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,char,char const *,unsigned int,unsigned int,unsigned int,unsigned int)const " (?_Fput@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@ABA?AV?$ostreambuf_iterator@DU?$char_traits@D@std@@@2@V32@AAVios_base@2@DPBDIIII@Z)<br />
server error LNK2019: unresolved external symbol _localeconv referenced in function "private: class std::ostreambuf_iterator<char,struct std::char_traits<char> > __cdecl std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > >::_Fput(class std::ostreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,char,char const *,unsigned int,unsigned int,unsigned int,unsigned int)const " (?_Fput@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@ABA?AV?$ostreambuf_iterator@DU?$char_traits@D@std@@@2@V32@AAVios_base@2@DPBDIIII@Z)<br />
server error LNK2019: unresolved external symbol _memset referenced in function "public: static char * __cdecl std::char_traits<char>::assign(char *,unsigned int,char)" (?assign@?$char_traits@D@std@@SAPADPADID@Z)<br />
server error LNK2019: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) referenced in function "char * __cdecl std::_Allocate<char>(unsigned int,char *)" (??$_Allocate@D@std@@YAPADIPAD@Z)<br />
server error LNK2019: unresolved external symbol __Getcvt referenced in function "public: struct _Cvtvec __thiscall std::_Locinfo::_Getcvt(void)const " (?_Getcvt@_Locinfo@std@@QBE?AU_Cvtvec@@XZ)<br />
server error LNK2019: unresolved external symbol "void * __cdecl operator new[](unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??_U@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) referenced in function "char * __cdecl std::_Maklocstr<char>(char const *,char *,struct _Cvtvec const &)" (??$_Maklocstr@D@std@@YAPADPBDPADABU_Cvtvec@@@Z)<br />
server error LNK2001: unresolved external symbol _WinMainCRTStartup<br />
server fatal error LNK1120: 43 unresolved externals
Why is that? Thanks!
PS: Sorry for long msg...
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
-- modified at 22:21 Thursday 13th April, 2006
|
|
|
|
|
how to convert from numeric types (such as double, int, long,...) to char[]?
(i want to show the number in a window, so i need to convert it to char)
|
|
|
|
|
|
Try using some of the numeric conversion functions, for example itoa(), ltoa().
|
|
|
|
|
Or you could use the sprintf() function. That's good for getting secific formatting.
|
|
|
|
|
|
union {
double d;
char[8] c;
} d2c;
|
|
|
|
|
Hi there.
While sprintf works, it is really a C solution. I just wanted to show you a C++ solution for creating a string to display by using streams.
<br />
#include <sstream><br />
<br />
double num1 = 3.143;<br />
<br />
std::ostringstream outStream;<br />
std::string outString;<br />
<br />
outStream << "Value of double is : " << num1;<br />
<br />
outString = outStream.str();<br />
<br />
label1->Text = gcnew String(outStream.str().c_str());<br />
Using the ostringstream, you will not have to worry about the size of your char array, or have a ptr to char and do any memory allocation/cleanup. All done for you.
Cheers
|
|
|
|
|
How could i get the size (height and width) of the screen by calling a windows API function?
Thanks!
|
|
|
|
|