|
Bitruder posted:I have a feeling it's because p_plugin is of type A*, however, my main program doesn't know what "B" is called... so I have to use type A*. Any ideas what I can do here? I've never tried using virtual function calls over a DLL boundary, but I wouldn't be surprised if you need to jump through one or two hoops. This looks like a nice tutorial: http://www.codeproject.com/KB/DLL/PluginSystem.aspx
|
# ? Mar 28, 2009 14:39 |
|
|
# ? Apr 29, 2024 11:49 |
|
TSDK posted:Your understanding is wrong: *repeats "thou shalt not try to use uninitialised pointers" one thousand times*
|
# ? Mar 28, 2009 14:48 |
|
DividesByZero posted:Why doesn't this work? My understanding is that scanf allocates memory and stores the read object at the pointer provided as the second argument. That is scanf("%s",names[i]) should store the scanned in string at the location pointed to by the ith element of names. Where am I doing something dumb? Is it because names[i] is not actually pointing anywhere yet since it's not initialised when I do the scanf? Now you know why this is wrong you might be tempted to use gets(). Don't. At the least use fgets() or if you want to go non standard and are using a GNU based system, use getline()
|
# ? Mar 28, 2009 17:03 |
|
I want to set up the repository so that each person working on the project can work on their own branch that might be a bit experimental and can incorporate their changes back into the trunk version after a certain amount of QA is done. The only problem is I have no idea how to do this and even if I messed around with it I have no idea if I'm doing it right. So what's the right way to accomplish this? Edit: gently caress I thought I was in the general thread Contero fucked around with this message at 02:10 on Mar 30, 2009 |
# ? Mar 29, 2009 03:42 |
|
By using git.
|
# ? Mar 29, 2009 03:44 |
|
Contero posted:I've used svn in groups for smaller programming projects, but it's never been very organized and I honestly don't know a lot about how to manage a repository. I'm about to start working on a new project and I want to make it a bit more organized. This isn't a c/c++ question, but anyway. As I understand it, if the main focus of your VCS is to allow developers to have their own play area, then a distributed solution (git, rather than svn) might be the way to go.
|
# ? Mar 29, 2009 03:56 |
|
Git is made for this sort of thing. I moved over to it a few months ago and find it to be more sensible than SVN on all fronts.
|
# ? Mar 29, 2009 06:45 |
|
What is a reasonable way to express a many-to-many relationship between objects of differing type with the ability of an object of either type to find out about it's relationships? There should be a mediator involved between any given relationship, but how would I accomplish the actual structure without just having lists that need traversing? For example [ObjectA]<-->[Mediator]<-->[ObjectB] Either object would be need to be able to query the mediator and find which objects are claiming a relationship. Ideally this would be similar to the STL::multimap that can be queried by either key or value.
|
# ? Mar 29, 2009 07:48 |
|
Look at Boost.Bimap: http://www.boost.org/doc/libs/1_38_0/libs/bimap/doc/html/index.html
|
# ? Mar 29, 2009 07:56 |
|
Avenging Dentist posted:Look at Boost.Bimap: http://www.boost.org/doc/libs/1_38_0/libs/bimap/doc/html/index.html Beautiful, thanks! Is that type of structure commonly known as a "bitmap"? I haven't seen it used that way before..
|
# ? Mar 29, 2009 08:26 |
|
Thug Bonnet posted:Beautiful, thanks! Is that type of structure commonly known as a "bitmap"? I haven't seen it used that way before.. Bimap, no T.
|
# ? Mar 29, 2009 08:27 |
|
Avenging Dentist posted:Bimap, no T. Yow, thanks again
|
# ? Mar 29, 2009 08:27 |
|
Thug Bonnet posted:Yow, thanks again But you can implement bimaps as adjacency matricies, stored as bitmaps.
|
# ? Mar 29, 2009 08:32 |
|
Luminous posted:I know you read the link the other guy posted and said it helped, but couldn't tell if you had actually found the solution to whatever you were doing.
|
# ? Mar 29, 2009 16:04 |
|
Hello everyone, I'm currently working on an array and file open/close program for C. My program has become rather wonky lately and is giving me strange values. Not included in the code below is a case where I set i = 0 and then proceeded to print its value to screen and I was rewarded with something similar to 4197468. Anyways, the number 4197468 is the result of this little statement down here which is a small chunk of the code, frankly it should be zero here as well so I'm at a loss. A friend of mine thinks I must be accessing files incorrectly but I honestly can't find the issue. Any help would be appreciated. code:
code:
code:
|
# ? Mar 29, 2009 17:47 |
|
code:
edit: If you make the correction, you'll see that diceRolls[35] is in fact 0. Also, using the debugger is better than sprinkling printfs around your code. Dijkstracula fucked around with this message at 18:13 on Mar 29, 2009 |
# ? Mar 29, 2009 18:06 |
|
Dijkstracula posted:
I stared at it blankly for a second, then I realized I R stupid. Thank you for this and thank you for the debugger. My array which didn't appear to be working correctly is now fixed as well.
|
# ? Mar 29, 2009 18:21 |
|
Haha, what the hell, how do I fix this problem? I'm using Visual Studio 2008 for reference. I'm trying to complete this little tutorial, http://www.codeproject.com/KB/IP/winsockintro01.aspx, and I'm getting this error: fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h> Now, I hunted down where windows.h is included and it is in winsock2.h. The author says that MFC support must be added, but this apparently creates a conflict, where I can't include windows.h. How do I get around this?
|
# ? Mar 30, 2009 16:36 |
|
What happens if you do what it tells you and don't explicitly include windows.h?
|
# ? Mar 30, 2009 16:46 |
|
I don't ever explicitly include it, I include winsock2.h.
|
# ? Mar 30, 2009 17:08 |
|
I don't know enough about MFC to figure out the header mess, but it looks like he only uses MFC for AfxBeginThread() so that he can have his little _getch() loop. Since WinSock is all you care about, you could not include MFC, change main tocode:
|
# ? Mar 30, 2009 18:15 |
|
edit: this was wrong
|
# ? Mar 30, 2009 18:19 |
|
Mach Won posted:I don't ever explicitly include it, I include winsock2.h. http://msdn.microsoft.com/en-us/library/09dd1ycd(VS.80).aspx posted:MFC supports Windows Sockets 1 but does not support Windows Sockets 2. Windows Sockets 2 first shipped with Windows 98 and is the version included with Windows 2000.
|
# ? Mar 30, 2009 18:42 |
|
I don't care which I use, I just want this to work. Why would that guy say to use winsock2.h in his tutorial if it doesn't work
|
# ? Mar 30, 2009 18:45 |
|
He says "Open the file stdafx.h and add the following line :- #include <winsock2.h>" Did you add it at the start? Try adding it at the end instead. edit: in fact this solution is in one of the comments: http://www.codeproject.com/KB/IP/winsockintro01.aspx?msg=2010952#xx2010952xx Look for the bit in stdafx.h where it says "// TODO: reference additional headers your program requires here". Pooball fucked around with this message at 23:50 on Mar 30, 2009 |
# ? Mar 30, 2009 20:43 |
|
I'm playing around with TMP in GCC 4.3.2's half-implementation of C++0x, and I was wondering if there was a way to somehow do the following:code:
|
# ? Mar 31, 2009 20:09 |
|
I was reading earlier, and saw this:quote:First, however, let’s start with a simple cache quiz: which code is faster? Can someone explain to me why? I havent't programmed in a while and I'm disappointed that I can't figure it out.
|
# ? Mar 31, 2009 21:18 |
|
Bob Morales posted:Can someone explain to me why? I havent't programmed in a while and I'm disappointed that I can't figure it out. Assume the structure in question is large. When you make large jumps (incrementing by width each iteration, instead of incrementing by 1) you increase the likelihood of a cache miss, because CPU caches bring in lines of adjacent words from memory at a time. So, with large jumps, the logic is essentially: read several words from memory, do operation on one of those words, read several different words from memory, etc. Much of the cache is wasted, and you tend to stall on memory accesses. With incremental jumps, the logic becomes: read several words from memory, do operation on first of them, do operation on next of them, do operation on next of them, etc, read next set of words from memory, etc. The CPU spends more time doing actual work, and less time doing memory accesses.
|
# ? Mar 31, 2009 21:26 |
|
It was an article on optimizing cache use. That makes perfect sense, I had a brain fart. I guess I wasn't aware that more memory was cached than actually accessed.
|
# ? Mar 31, 2009 21:59 |
|
Can someone help me with this error: error C2664: 'v8::FunctionTemplate::New' : cannot convert parameter 1 from 'v8::Handle<T> (__cdecl *)(const v8::Arguments &)' to 'v8::InvocationCallback' Relevant definitions: code:
|
# ? Apr 1, 2009 20:19 |
|
code:
code:
|
# ? Apr 2, 2009 19:48 |
|
I've beat my head against this for like 3 wasted hours and it must just be my misunderstanding of c++. In file some_consts.h I have code:
code:
code:
code:
code:
code:
code:
Compiler is VS2008.
|
# ? Apr 2, 2009 21:06 |
|
Plastic Jesus posted:In file some_consts.h I have code:
It's blank because you're running into the static initialization order fiasco. Solution is to declare (but not define) Foo::MyString in your header: code:
code:
Standish fucked around with this message at 22:12 on Apr 2, 2009 |
# ? Apr 2, 2009 22:03 |
|
Standish posted:By default variables have file scope, so every time you do #include "some_consts.h" you're creating a new copy of MyString with the scope of the file that includes it (remember #include is really really dumb and just does plain text substitution). Completely false. This only applies to objects which have internal linkage, as specified by static (or, more-or-less, by anonymous namespaces). File scope is a completely different concept from linkage and refers to the lexical scope of an identifier, not its linkage. It doesn't make sense to talk about file scope being default because you must explicitly declare an identifier at file scope for it to have file scope. EDIT: Didn't see the const. Const variables, by default, do have internal linkage. The "solution" doesn't actually solve anything though, because it still relies on a particular static initialization order. EDITx2: The real solution is to just use a const char[] Avenging Dentist fucked around with this message at 22:34 on Apr 2, 2009 |
# ? Apr 2, 2009 22:19 |
|
If I have a character array that's going through a loop and constantly getting new information, what's the best way to stop things like this from happening/reset them each time throughquote:Hi
|
# ? Apr 2, 2009 22:33 |
|
Null-terminate your strings.
|
# ? Apr 2, 2009 22:35 |
|
Avenging Dentist posted:EDIT: Didn't see the const. Const variables, by default, do have internal linkage. The "solution" doesn't actually solve anything though, because it still relies on a particular static initialization order. Yah, I tried that solution and it did nothing (except make the string empty in CLogger while have content in MyUtil). Adding static made no difference in either approach. Doing cost char* is just so ugly. And as a larger solution, how would I do this sort of thing with anything that's not a base type? Is it just not possible a namespace level?
|
# ? Apr 2, 2009 22:53 |
|
Plastic Jesus posted:Doing cost char* is just so ugly. What. Who cares? Plastic Jesus posted:And as a larger solution, how would I do this sort of thing with anything that's not a base type? Is it just not possible a namespace level? The link in Standish's post explains one (of several) solutions to the problem.
|
# ? Apr 2, 2009 23:23 |
|
Avenging Dentist posted:What. Who cares? Anyone who wants to pass a const string& instead of a const char * to a function? Or anyone who wants to use template string constants to reduce pain when you need support unicode? If I just cared about solving this exact problem I'd have used a #define and moved on. Avenging Dentist posted:The link in Standish's post explains one (of several) solutions to the problem. Calling a function isn't really a solution to this problem. This is an extremely easy (and "effective" even) thing to do at the class level, I'm just wondering if it's something that can only be done within a class. And if so, why was that not mentioned in Meyers's book?
|
# ? Apr 2, 2009 23:40 |
|
|
# ? Apr 29, 2024 11:49 |
|
Plastic Jesus posted:Anyone who wants to pass a const string& instead of a const char * to a function? Or anyone who wants to use template string constants to reduce pain when you need support unicode? If I just cared about solving this exact problem I'd have used a #define and moved on. Luckily for you, char* can be passed to any function that accepts an std::string (yes, I already know you're going to whine about the "efficiency" of constructing a new string because newbie programmers loving love unnecessary micro-optimizations). You can also use TCHAR in Windows, and do similar stuff in Unix, though I'd recommend against it, since sizeof(wchar_t) == 4 on most Unixes, and you would be (rightly) laughed at for using UTF-32. Also lol at the idea that using templated strings would do anything to make Unicode less painful. The C++ Standard Library's Unicode support is minimal at best. Besides that, you still have a string literal in your code that you'd need to adjust for Unicode. std::wstring doesn't accept narrow character strings. Hell, the size of wide characters isn't even specified (as implied above). Plastic Jesus posted:Calling a function isn't really a solution to this problem. Yes it is. You do understand what static inside of a function denotes, right? Plastic Jesus posted:This is an extremely easy (and "effective" even) thing to do at the class level, I'm just wondering if it's something that can only be done within a class. That's because you don't understand C's (and by extension, C++'s) compilation model. If you did, the solution would be obvious to you. Plastic Jesus posted:And if so, why was that not mentioned in Meyers's book? "Oh no, book X doesn't tell me how to solve a particular problem, better complain about it!"
|
# ? Apr 3, 2009 00:04 |