|
The_Franz posted:I don't think so. Even if the void* types of the inline function parameters are discarded, he is still casting the pointer types to int* and then dereferencing the value, not casting the values directly. That shouldn't do any conversions or rounding.
|
# ? Aug 21, 2013 14:40 |
|
|
# ? May 17, 2024 11:34 |
|
Continuing on my time management woes, if I want to zero out a tm struct (or any other POD object for that matter), should I do memset(&tmObj, 0, sizeof(tm)) or memset(&tmObj, 0, sizeof(tmObj)), or does it actually matter? (or am I doing it wrong and am about to get my dick bitten off?)
Ciaphas fucked around with this message at 22:52 on Aug 22, 2013 |
# ? Aug 22, 2013 22:47 |
|
Ciaphas posted:Continuing on my time management woes, if I want to zero out a tm struct (or any other POD object for that matter), should I do memset(&tmObj, 0, sizeof(tm)) or memset(&tmObj, 0, sizeof(tmObj)), or does it actually matter? (or am I doing it wrong and am about to get my dick bitten off?) Between that and sizeof(tmObj) it doesn't matter, but sizeof(tmObj) is generally preferred in that then if something gets refactored in future such that now it's a different kind of object, and you still want to zero it, you don't have to change the code. On the other hand, if you later extended struct tm into some sort of child class, and tmObj is now of that extended class, and you only wanted to zero the struct tm part of it, then sizeof(struct tm) would be the better way. But in practice the answer is mostly it doesn't matter.
|
# ? Aug 22, 2013 22:59 |
|
Any reason why some simple integer math goes randomly sideways? The code's more or less this:code:
The actual bits if anyone cares: code:
code:
Combat Pretzel fucked around with this message at 19:28 on Aug 31, 2013 |
# ? Aug 31, 2013 19:25 |
|
Not seeing any broken math in your sample output there: lenTempbuf (4410) * requestedChannels (2) * sizeof float (4) == s (35280). Are you sure that tempbuf is large enough to hold the data you're trying to copy out of it (it's a read that fails, not a write)?
|
# ? Sep 1, 2013 00:45 |
|
It turned out to be sort of a clusterfuck. I was using the proxy function in two places and forgot to remove the unnecessary use of it, before adding all the logging, leading me on a wild goose chase. Turned out to be some bad math making, i.e. the multiplication with requestedChannels, the reads (and the output buffers) double of what they should have been. The upper layers are just test code that didn't do any checks, so the too large buffers went unnoticed. Anyway, the reads only failed when the related memory allocation was at the end of the heap, tripping the virtual memory manager or whatever, which didn't always happen depending how the heap was being fragmented on app start. Visual Studio displaying a call stack like a swiss cheese didn't help either. Which got all of this madness started to begin with. It showed me the memcpy that broke and a caller two levels up, but nothing in between. Combat Pretzel fucked around with this message at 03:05 on Sep 1, 2013 |
# ? Sep 1, 2013 03:03 |
|
Combat Pretzel posted:It showed me the memcpy that broke and a caller two levels up, but nothing in between. http://randomascii.wordpress.com/2013/08/19/developers-rejoicewindows-7-stack-corruption-fixed/ may be relevant.
|
# ? Sep 1, 2013 03:16 |
|
Ciaphas posted:I hate this/these loving language(s). OneEightHundred fucked around with this message at 15:31 on Sep 1, 2013 |
# ? Sep 1, 2013 15:25 |
|
Plorkyeran posted:http://randomascii.wordpress.com/2013/08/19/developers-rejoicewindows-7-stack-corruption-fixed/ may be relevant.
|
# ? Sep 1, 2013 23:43 |
|
If I dont want or need a cross platform GUI, for Windows development, is MFC the way to go? This is for a personal project. I've used Qt before at work, and I'd rather avoid it.
|
# ? Sep 2, 2013 08:51 |
|
xgalaxy posted:If I dont want or need a cross platform GUI, for Windows development, is MFC the way to go? I'd say C#/.net, which is mostly quite nice - but if you want c++ I'll refrain from giving unfounded advice.
|
# ? Sep 2, 2013 09:13 |
|
Computer viking posted:I'd say C#/.net, which is mostly quite nice - but if you want c++ I'll refrain from giving unfounded advice. I could go C# for the GUI I guess, but I'd have to use /CLR or whatever it is so I can write C++ as well,
|
# ? Sep 2, 2013 09:29 |
|
Is there an introduction to creating/editing makefiles that doesn't assume I know anything about g++ commands? I'd been using MSVC 2010 for a few months, since that's what we were provided in my first programming class, but the professor of my current class (at a different school) recommends we get familiar with NetBeans on Linux, which apparently (judging by my difficulty thus far) means we need to deal with makefiles. While this may be covered soon in the class, I'd like to get a head start on it if I can.
|
# ? Sep 2, 2013 14:45 |
|
xgalaxy posted:If I dont want or need a cross platform GUI, for Windows development, is MFC the way to go? I would reckon so, yes. Personally, I'm rubbish at it but would love to be better, but the guys I know who use it a lot can knock up functional UIs very quickly (and use it as the weapon of choice for small windows only tools) If you use Visual Studio then there are a bunch of things that make the MFC stuff much easier too.
|
# ? Sep 2, 2013 14:54 |
|
hooah posted:Is there an introduction to creating/editing makefiles that doesn't assume I know anything about g++ commands? I'd been using MSVC 2010 for a few months, since that's what we were provided in my first programming class, but the professor of my current class (at a different school) recommends we get familiar with NetBeans on Linux, which apparently (judging by my difficulty thus far) means we need to deal with makefiles. Rather than directly creating/editing your own Makefiles, I'd recommend looking into a higher level build file generator like CMake. Basically means you set up your build in CMakeLists.txt and CMake can use that to generate either Makefiles, or VS2010 projects, or XCode projects, etc, etc. Saves on some grunt work. There's some alternatives to cmake like scons, premake, gyp etc, too. For something simple it probably doesn't really matter what you use. EDIT: Assuming this is OK for your class of course, and Makefiles aren't actually themselves on the curriculum.
|
# ? Sep 2, 2013 16:48 |
|
I really can't imagine MFC ever being the correct choice for a new project.
|
# ? Sep 2, 2013 21:08 |
|
Windows Forms is pretty much the thing to use for Windows-only UI right now. If you need native code with it then just write a mixed-mode app. e: WPF is probably better for larger ongoing projects, WinForms is better for small stuff because WPF's setup time is annoying (gently caress XAML). OneEightHundred fucked around with this message at 22:23 on Sep 2, 2013 |
# ? Sep 2, 2013 21:17 |
|
If you don't need to use C++, WPF is the way to go. It's probably the way to go even if you need C++. Don't use MFC jesus christ.
|
# ? Sep 2, 2013 21:34 |
|
Plorkyeran posted:I really can't imagine MFC ever being the correct choice for a new project. (This is not a recommendation of the old stuff.)
|
# ? Sep 2, 2013 23:41 |
|
Is C99 widespread enough that it can be safely used in a library meant for public consumption, or should I be sticking to C89? Related, what's the go-to utility library for C these days, Apache or Glib? e: Actually I would love any links to good resources about modern C. I'm stuck in C++ land.
|
# ? Sep 3, 2013 00:30 |
|
more like dICK posted:Is C99 widespread enough that it can be safely used in a library meant for public consumption, or should I be sticking to C89? Related, what's the go-to utility library for C these days, Apache or Glib? Microsoft's support for C99 is somewhere between patchy and nonexistent, so if you want people to compile it in visual studio then stick to C89.
|
# ? Sep 3, 2013 00:43 |
|
more like dICK posted:Is C99 widespread enough that it can be safely used in a library meant for public consumption, or should I be sticking to C89? Related, what's the go-to utility library for C these days, Apache or Glib? Apache and glib are both good choices but I actually like GTK+'s API so maybe I'm insane.
|
# ? Sep 3, 2013 01:05 |
|
glib is sort of a nightmare on Windows. I've never actually encountered a project that uses APR.
|
# ? Sep 3, 2013 01:06 |
|
Qwertycoatl posted:Microsoft's support for C99 is somewhere between patchy and nonexistent, so if you want people to compile it in visual studio then stick to C89. 2013 is supposed to implement the majority of it.
|
# ? Sep 3, 2013 01:54 |
|
It is probably easier to learn C# and WPF from scratch than to learn just a Windows C++ GUI framework from scratch. e: and C++/CLI (not the newer WinRT stuff or whatever) is intended only for use gluing other components together. It's not that you can't do actual projects in it from a language perspective, but your tools are gimped: There's no Intellisense, and at least VS2010 is buggy as hell when you've got a C++/CLI project in your solution.
|
# ? Sep 3, 2013 02:07 |
|
Yeah, I would strong advise against using C++/CLI for anything other than creating .NET bindings for a C++ library. Even a C library is likely to be easier with PInvoke in the long run.
|
# ? Sep 3, 2013 03:16 |
|
Having done both, I'd say they're about the same. The problems you face in each case are completely different but the volume of them seems similar.
|
# ? Sep 3, 2013 03:28 |
|
GrumpyDoctor posted:VS2010 is buggy as hell when you've got a C++/CLI project in your solution.
|
# ? Sep 3, 2013 04:51 |
|
OneEightHundred posted:It's not that buggy, the main problem is that you have to manually set debugging to mixed mode or it'll vomit any time something goes wrong in the managed code. The Auto debug mode option basically doesn't work. The WPF designer will throw an exception under certain circumstances when you try to load design view of your XAML (you'll have to unload the C++/CLI project and remove it from the solution), and sometimes you have to do solution-wide rebuilds for no reason. It's pretty easy to actually crash cl.exe in C++/CLI code.
|
# ? Sep 3, 2013 06:32 |
|
hooah posted:Is there an introduction to creating/editing makefiles that doesn't assume I know anything about g++ commands? I'd been using MSVC 2010 for a few months, since that's what we were provided in my first programming class, but the professor of my current class (at a different school) recommends we get familiar with NetBeans on Linux, which apparently (judging by my difficulty thus far) means we need to deal with makefiles. Simple makefiles aren't too tough. If your project's not that big then it's probably easier to learn to write a simple makefile than to tangle with cmake, though cmake's not too bad either. Here's some basics about writing a makefile. Here's how to make 'myprog' from myprog.cpp code:
Here's how to make 'myprog' from myprog.cpp and myclass.cpp code:
You can compile individual source files one at a time into object files then later link them into an executable or a library e.g. code:
The syntax is getting repetitive though. GNU Make has Automatic Variables that can be used to keep from repeating stuff so much. Here's the last makefile but with automatic variables: code:
But we can do better. Make also has Pattern Rules, a type of Implicit Rule. You can use pattern rules to say "this is how to make any .o file from a corresponding .cpp file". code:
So this is pretty good! Not a ton of typing and all of the source is building. But we can do a little better by adding some make variables. I'm going to use several fairly common variables here. code:
Another variable has been added to allow you to pass compile flags to g++, CXXFLAGS. In it, I've put -Wall. You could put other flags there too, g++ has many options. The -I option, listed in IFLAGS, allows you to tell make where to look for header files (if you didn't put them in the base directory or if you've included a system header that g++ can't find). Here, I've assumed your project has an 'include' directory. Lastly, I've added a variable to store your object file names and called it OBJECTS. This is a fairly common thing to do and it can become useful to have OBJECTS listings at the top of the file if you need to do things like build multiple binaries and libraries inside the same makefile. One last trick. It's a tad nicer to list sources instead of objects since sources are what you've actually got, even though objects are the prereqs for myprog. Here's a sample of how to use make's pattern substitution tools to get a list of objects from a list of sources. code:
|
# ? Sep 5, 2013 03:11 |
|
I would advise using the -Wextra flag as well, as it adds a bunch of useful warnings that -Wall doesn't.
|
# ? Sep 5, 2013 04:12 |
|
Dren posted:makefile info Thanks, that's way more helpful than most of the stuff I'd found by searching, and more helpful than any of it. Now I can use NetBeans again!
|
# ? Sep 5, 2013 12:58 |
|
hooah posted:Thanks, that's way more helpful than most of the stuff I'd found by searching, and more helpful than any of it. Now I can use NetBeans again! One huge gotcha for people coming from procedural languages is the way variable expansion is handled in make. Expansion of variables created with the '=' operator is deferred until the variable is used. You can read more about variable behavior at The Two Flavors of Variables. Deferred recursive variable expansion mostly will behave the way you expect. Until, that is, it looks like you're defining something but the definition doesn't seem to be activated when you need it and you can't figure out what is going on. If you'd like to get a deeper understanding of make, please read Writing Makefiles and pay particular attention to the section How make Reads a Makefile. Understanding how make processes a makefile can save you from some enormous headaches with make.
|
# ? Sep 5, 2013 16:39 |
|
I got a programming pattern question. I have an established library and for some (not all) of the exposed classes, I'd like to place proxies in front of them (in order to alter the functionality). For the components of the library that are not proxied, I'd like them to maintain their original functionality. I'd like my proxy layer to offer the exact same interface as the library that it's sitting in front of (same namespaces, same symbols). The problem is that the proxy layer also has to link against the library itself so, if it exposes the exact same interface, i'll end up with symbol name conflicts. Is there some elegant way to do this (without editing the source of the original library)?
|
# ? Sep 6, 2013 18:37 |
|
shodanjr_gr posted:Is there some elegant way to do this (without editing the source of the original library)? Edit: and you make sure the original library's headers aren't included by your code other than in the proxy's cpp files. roomforthetuna fucked around with this message at 22:25 on Sep 6, 2013 |
# ? Sep 6, 2013 20:13 |
|
If you don't want to add an additional namespace to your calling code, it gets a bit gross. In short, you never want the calling code to see the original namespace, only the wrapper's: original.h: code:
code:
code:
|
# ? Sep 6, 2013 20:45 |
|
High Protein posted:If you don't want to add an additional namespace to your calling code, it gets a bit gross. In short, you never want the calling code to see the original namespace, only the wrapper's: Thanks, this is actually very neat. However, the situation is slightly more complicated (I should have probably included this in the original question). The classes that I want to proxy are parts of a complex hierarchy (a scenegraph) so an approach like this would probably break interchangeability (unless every class in the hierarchy was put behind a proxy). Instead of using a pimpl approach (which would also require writing function stubs for every function in originalcls). Is there a way to get this to work through inheritance? Optimally, wrappercls would want to inherit from originalcls in order to get all the functionality and just overload relevant methods. But obviously I wouldn't be able to do: code:
Would this work? code:
|
# ? Sep 6, 2013 21:43 |
|
Inheriting from a class in a way that it wasn't intended to be inherited from is generally considered Very Poor Form: in the absolute best case the code is difficult to understand, in most cases something doesn't work right, and in the worst case you get memory leaks or crashes or something. It sounds like this will actually be a problem for you, because you want "interchangeability" but presumably the functions you're trying to wrap weren't declared as virtual, so if you try to use them as base methods you won't actually dispatch to the wrapped versions. (If they were declared as virtual then you don't have a problem here.) If you did manage to kludge together a way to statically dispatch to something with your wrapped behavior without secretly injecting some namespace or something, I can't see how you wouldn't run afoul of the one definition rule, but maybe one of the wizards here has a magic solution.
|
# ? Sep 6, 2013 22:22 |
|
What you're doing sounds like a bad idea, but to answer the original question of "how do I replace some of the symbols from a library", one option is to write a wrapper around those symbols, compile the wrapper + original library into a shared library which does not expose the original symbol names, then write a second wrapper which maps the wrapped symbols back to the original names. I would not recommend doing this unless you have no other options.
|
# ? Sep 6, 2013 22:41 |
|
|
# ? May 17, 2024 11:34 |
|
If you have the source it's sounding like you might be better off writing a patch to the library and recompiling it.
|
# ? Sep 7, 2013 02:44 |