• What do you need help with? Version 1
    5,001 replies, posted
There seems to be no toggle of "runtime library", only a selection of runtime libraries such as multi-threaded debug. Oh and yeah, we mis-understood each other about the whole map thing. I was saying a custom class for effects, not handling them. I would use a stl map for that, like you said.
[QUOTE=WTF Nuke;25446562]There seems to be no toggle of "runtime library", only a selection of runtime libraries such as multi-threaded debug.[/QUOTE] Did you try building with each available setting?
[QUOTE=ZeekyHBomb;25446615]Did you try building with each available setting?[/QUOTE] I did now.
Anyone know of any thing on overriding a stream class in .NET? I need to map a series of possibly fragmented sectors, into a single stream.
Fiddling with writing a simple file format in C++ for levels in my game I wanted to try and make it an unformatted, non human-readable format because I've never done that before. I was researching things to do with writing various data types to the file, and I came across something like this code: [cpp]int val = 5; stream.write(reinterpret_cast<const char*>(&val), sizeof(val));[/cpp] Which brought up a question. As I understand it, reinterpret_cast is used for converting between various pointer types (int* to char* in this case) Is there any reason to use it over a standard (const char*)val style cast?
The 'standard' (const char*) style cast is called C-style cast. And it's called that because that's the only reason it exists in C++: C-compatibility. C++-style casts make it much more obvious what is happening. For example the static_cast is done statically, i.e. in compile-time. The dynamic_cast is done dynamically, i.e. in run-time. The const_cast is used to only change the const-ness, though not the type. And finally the reinterpret_cast simply reinterprets the value as something else (e.g. like interpreting a pointer to int as if it were a pointer to char in your line of code).
[QUOTE=ZeekyHBomb;25462755]C++-style casts make it much more obvious what is happening.[/QUOTE] Not really.
[QUOTE=ROBO_DONUT;25463515]Not really.[/QUOTE] Yes really. Otherwise you have to know the order defined by the standard by heart. The C++-style casts are more specific and describe exactly what's going on in every case.
[QUOTE=gparent;25463619]Yes really. Otherwise you have to know the order defined by the standard by heart. The C++-style casts are more specific and describe exactly what's going on in every case.[/QUOTE] I can see the need for a dynamic_cast, but static_cast, reinterpret_cast, and const_cast don't do anything C-style casting doesn't do more concisely and consistently. The fact that C++ needs four extraordinarily verbose functions to do casting is just one of many irritating design flaws.
[QUOTE=ROBO_DONUT;25463774]I can see the need for a dynamic_cast, but static_cast, reinterpret_cast, and const_cast don't do anything C-style casting does more concisely and consistently. The fact that C++ needs four extraordinarily verbose functions to do casting is just one of many irritating design flaws.[/QUOTE] Yeah, they should be called cc<T>, dc<>, sc<T>, dc<T> so that everything is unreadable. And knowing what cast is going on instead of having to figure it out is more concise, whether you have a biased love of C or not. EDIT: Except for const_cast I suppose.
Thanks for the replies It does look a bit messy to me, having these verbose operators lying around my code... but I guess if it's the "proper" way of doing it in C++ then I'd better get used to it. I think I have the level saving fine, but reading it back in is proving to be difficult... I need to play around with it some more I think
[QUOTE=gparent;25463837]And knowing what cast is going on instead of having to figure it out is more concise[/QUOTE] static cast: int i = (int)1836.34234f; reinterpret cast: float f = 1836.34234f; int *i = (int*)&f; const cast: const int i = 1836; int j = (int)i; Sooooooooooooooooo complicated and difficult to read. The problem with C++ is that it tries to make distinctions where they shouldn't be made. It's all casting. There's no need to pretend casting pointers is different than casting integers. [QUOTE=gparent;25463837]whether you have a biased love of C or not.[/QUOTE] Everyone has a bias, anyone who says they don't is a fucking liar, and having a bias doesn't mean shit about your argument.
I'm trying to convert screen coordinates (so mouse position) into matrix coordinates. I know the camera position and the angles (pitch, yaw) as well as anything I need to know about the matrix (by matrix, I mean a square heightmapped terrain). What I tried to do was turn the camera angles into a vector, use the mouse position combined with fov and screen size to get the mouse vector. Then, I use the MatrixData table (containing the height of the middle point of each tile on the matrix) and, for each tile: - Calculate the distance from height to the camera - Trace the mouse vector from the camera by the calculated distance - Calculate the distance between the endpoint of the trace and the position of the middle of the tile - Find the tile with the lowest distance, there's my tile It kinda works, but it's inaccurate and if I rotate the camera (so that it still aims at the center of the matrix, but from a different viewpoint) it goes all screwy (I suspect the trig in the first part of the function). Can anyone suggest an easier/more accurate/whatever way? [code]local mx, my, fmx, fmy, pit, yaw, dirX, dirY, dirZ, lowestDist, lX, lZ, tempDist, vec local function TRACE( distance ) return camX+dirX*distance, camY+dirY*distance, camZ+dirZ*distance end local tempX, tempY, tempZ local function TRACE_DIST_POINT( distance, x, y, z ) tempX, tempY, tempZ = TRACE( distance ) return math_sqrt( (x-tempX)^2 + (y-tempY)^2 + (z-tempZ)^2 ) end local function TRACE_POINT( x, y, z ) tempDist = math_sqrt( (x-camX)^2 + (y-camY)^2 + (z-camZ)^2 ) return TRACE_DIST_POINT( tempDist, x, y, z ) end local sensX = 0.6 local sensY = 0.6 function terrainmgr.CalcCursorTile( sw, sh, fov ) mx, my = core.MousePos() fmx, fmy = (mx/sw - 0.5)*sensX, (0.5 - my/sh)*sensY pit = math_rad( fmy*fov-70 ) yaw = math_rad( fmx*fov + camAng ) --dirX = math_sin( yaw ) * math_cos( pit ) dirX = math_sin( yaw ) dirY = math_sin( pit ) dirZ = math_cos( yaw ) * math_cos( pit ) lowestDist = -1 for x=0, mSize-1 do for z=0, mSize-1 do vec = DataMap[ (x*mSize)+z ] tempDist = TRACE_POINT( vec[1], vec[2], vec[3] ) if (lowestDist == -1) or (tempDist < lowestDist) then lowestDist = tempDist lX = x lZ = z end end end --print( "User clicked on " .. lX .. "," .. lZ .. " (relative)" ) --print( "User clicked on " .. lX+windowX .. "," .. lZ+windowZ .. " (absolute)" )]] --print( "Direction is " .. dirX .. "," .. dirY .. "," .. dirZ ) return lX+0.5, lZ+0.5 end[/code]
[QUOTE=ROBO_DONUT;25464154]static cast: int i = (int)1836.34234f; reinterpret cast: float f = 1836.34234f; int *i = (int*)&f; const cast: const int i = 1836; int j = (int)i; Sooooooooooooooooo complicated and difficult to read. [/QUOTE] Proving that trivial examples are trivial is trivial. [QUOTE=ROBO_DONUT;25464154]Everyone has a bias, anyone who says they don't is a fucking liar, and having a bias doesn't mean shit about your argument.[/QUOTE] It's different when that bias leads someone to automatically think every single new feature of a language is useless/shit when they barely take the time to understand it. Which makes me not care about this argument, since talking to you about C or C++ is a waste of time anyway.
Anyone know of any thing on overriding a stream class in .NET? I need to map a series of possibly fragmented sectors, into a single stream. I am currently working on a Compund Binary File Format reader/writer, I can read them perfectly, but writing I am finding I need this.
Just to throw my two cents in on this new argument, here's my opinion on casting. [cpp] #include <string> #include <sstream> #include <iostream> class X { public: explicit X(const std::string& name) : name(name) { } operator std::string(void) { std::ostringstream stream; stream << "Hello, my name is " << name << ". You killed my father. Prepate to die" << std::endl; return stream.str(); } /*operator const char*(void) { std::ostringstream stream; stream << "Stop that rhyming now, I mean it!" << std::endl; stream << "Anybody want a peanut?" << std::endl; return stream.str().c_str(); }*/ private: std::string name; }; int main(void) { X x("Inigo Montoya"); std::cout << static_cast<std::string>(x); std::cout << (std::string)x; std::cout << std::string(x); //std::cout << static_cast<const char*>(x); //std::cout << (const char*)x; //std::cout << const char*(x); } [/cpp] Never go against C-cillian, when casting is on the line. :v:
[QUOTE=Chandler;25465994]Just to throw my two cents in on this new argument, here's my opinion on casting.[/QUOTE] I solve the problem by designing my code as to reduce the necessity of casting :]
quick conceptual question, I don't really understand how you can have an interface as a return type for a method in java. Like what is the significance of that? How would it be of any use?
[QUOTE=gparent;25466023]I solve the problem by designing my code as to reduce the necessity of casting :][/QUOTE] As you can see from my example above however, it can be very useful. One nice/terrible thing about operator overloads in C++, is that you can overload the casting operator. (i.e. designing a set of classes to dump JSON when casted to std::string, or splitting a certain string by commas when casted to std::vector<std::string>.) The issue becomes then, of the c-style vs. c++ casting, especially if any of those classes have a protected copy constructor, or don't have a copy constructor at all (in which case the third version will fail, as it is ambiguous).
Hmm... it seems I could really do with some help on making a workable binary file format.. Does anyone know of any good articles about this? I can't find anything useful
It should be rather straight forward and easy. What problem did you run into?
A combination of being exceedingly dumb and ill today.. Maybe I should just stop coding until I'm better again :(
[QUOTE=Chris220;25467630]A combination of being exceedingly dumb and ill today.. Maybe I should just stop coding until I'm better again :([/QUOTE] Depends what the binary file is for really, I mean I wouldn't use this Compound Binary Format, with an image for example, they are for Office files etc.
God I'm stupid I have it working now I'll just say it was a valuable learning experience, and move along swiftly
[QUOTE=WTF Nuke;25445025]Oh damn I forgot about dependencies, so I did that. Still I got these errors: [code]1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "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> >::operator=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(int)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::_Container_base_secure::_Orphan_all(void)const " (?_Orphan_all@_Container_base_secure@std@@QBEXXZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::`vbase destructor'(void)" (??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(void)const " (?str@?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??$?6DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "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> >::substr(unsigned int,unsigned int)const " (?substr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV12@II@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::find_last_of(char const *,unsigned int)const " (?find_last_of@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIPBDI@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >(int)" (??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::_String_base::~_String_base(void)" (??1_String_base@std@@QAE@XZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::_Container_base_secure::~_Container_base_secure(void)" (??1_Container_base_secure@std@@QAE@XZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::_Container_base_secure::_Container_base_secure(void)" (??0_Container_base_secure@std@@QAE@XZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::ios_base::width(int)" (?width@ios_base@std@@QAEHH@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,int)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static bool __cdecl std::char_traits<char>::eq_int_type(int const &,int const &)" (?eq_int_type@?$char_traits@D@std@@SA_NABH0@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static int __cdecl std::char_traits<char>::eof(void)" (?eof@?$char_traits@D@std@@SAHXZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::fill(void)const " (?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " (?flags@ios_base@std@@QBEHXZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::ios_base::width(void)const " (?width@ios_base@std@@QBEHXZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Lock(void)" (?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: bool __thiscall std::ios_base::fail(void)const " (?fail@ios_base@std@@QBE_NXZ) already defined in ticppd.lib(ticpp.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(void)" (?_Decref@facet@locale@std@@QAEPAV123@XZ) already defined in ticppd.lib(ticpp.obj) 1>libcpmtd.lib(ios.obj) : error LNK2005: "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" (?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(ios.obj) : error LNK2005: "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd@ios_base@std@@SAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(locale0.obj) : error LNK2005: "void __cdecl _AtModuleExit(void (__cdecl*)(void))" (?_AtModuleExit@@YAXP6AXXZ@Z) already defined in msvcprtd.lib(locale0_implib.obj) 1>libcpmtd.lib(locale0.obj) : error LNK2005: __Fac_tidy already defined in msvcprtd.lib(locale0_implib.obj) 1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register@facet@locale@std@@CAXPAV123@@Z) already defined in msvcprtd.lib(locale0_implib.obj) 1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (?_Init@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@std@@SAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>LIBCMTD.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __CrtSetCheckCount already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(lconv.obj) : error LNK2005: _localeconv already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(atox.obj) : error LNK2005: _atoi already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(_ctype.obj) : error LNK2005: _isalpha already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(_ctype.obj) : error LNK2005: _isspace already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(_ctype.obj) : error LNK2005: _isalnum already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(tolower.obj) : error LNK2005: _tolower already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(sprintf.obj) : error LNK2005: _sprintf_s already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMTD.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj) 1>LIBCMTD.lib(errmode.obj) : error LNK2005: ___set_app_type already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(dbgrptw.obj) : error LNK2005: __CrtDbgReportW already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMTD.lib(vsnprnc.obj) : error LNK2005: __vsnprintf_s already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library 1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library 1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall citemvalues::citemvalues(void)" (??0citemvalues@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'itemvalues''(void)" (??__Eitemvalues@@YAXXZ)[/code][/QUOTE] Repost for new toast.
If i wanted to write a irc server then where would i look to get a tutorial or documentation.
I have this really simple but frustration problem: [cpp] SENDER: foreach (KeyValuePair<String, PictureBox> pb in H_UTIL.pBList) { pb.Value.Click += new EventHandler(SelectedTileChanged); } Reciver: private static void SelectedTileChanged(object sender, EventArgs e) { //I need pb.Key to be passed here } [/cpp]
override EventArgs and create a version that contains that variable
[QUOTE=Vbits;25481460]override EventArgs and create a version that contains that variable[/QUOTE] Fixed it like this [cpp] private static void SelectedTileChanged(object sender, EventArgs e) { PictureBox pb = (PictureBox)sender; MessageBox.Show(pb.Name + " was clicked!"); } [/cpp]
[QUOTE=Pirate Ninja;25481395]I have this really simple but frustration problem: [cpp] SENDER: foreach (KeyValuePair<String, PictureBox> pb in H_UTIL.pBList) { pb.Value.Click += new EventHandler(SelectedTileChanged); } Reciver: private static void SelectedTileChanged(object sender, EventArgs e) { //I need pb.Key to be passed here } [/cpp][/QUOTE] [cpp] SENDER: foreach (var pb in H_UTIL.pBList) { pb.Value.Click += (s,e) => SelectedTileChanged(pb.Key); } Reciver: static void SelectedTileChanged(object key /* couldn't find PictureBox.Key on MSDN, don't know what type it is */) { //I need pb.Key to be passed here } [/cpp] [editline]18th October 2010[/editline] [QUOTE=Pirate Ninja;25481507]Fixed it like this [cpp] private static void SelectedTileChanged(object sender, EventArgs e) { PictureBox pb = (PictureBox)sender; MessageBox.Show(pb.Name + " was clicked!"); } [/cpp][/QUOTE] or that
Sorry, you need to Log In to post a reply to this thread.