|
NestedObject &NestedObject::operator=(const NestedObject &other) doesn't resize annotate. Beyond that, use a memory debugger --- if you're on Linux or OS X, use Valgrind. It's quite possible that the "unimportant stuff" you cut out is what's actually screwing up.
|
# ¿ Aug 22, 2010 21:34 |
|
|
# ¿ May 17, 2024 10:20 |
|
operator=. And you have some temporaries there.
|
# ¿ Aug 28, 2010 02:14 |
|
code:
|
# ¿ Sep 9, 2010 04:27 |
|
I hope the profile was at least done with a fully optimized build?
|
# ¿ Sep 14, 2010 19:49 |
|
Hmm. well, there is whatever addr2line does, too, if you don't mind linking to libbfd (which may be acceptable for purely debug stuff..) Does the compiler in question use the same C++ ABI as gcc, BTW? If it does, abi::__cxa_demangle might be of some use.
|
# ¿ Sep 29, 2010 19:26 |
|
Ledneh posted:The compiler in question is Sun CC provided with Sun Studio 12.1. I don't really want to link anything that's going to murder production performance, either, though I want to be able to get the stack trace in production for the sake of more useful exception info. Well, the issue is more that libbfd is GPL'd, which is quite likely to be an issue for production stuff. Hmm. An another option: if you have good control over production binaries, it may be possible to do the line number processing off-line, though you'd need to extract the memory map to know which libraries are located where. Sounds like one of those sorta-simple but pretty fiddly kind of tasks (again, addr2line code may be a good starting point for the post-processing tool).
|
# ¿ Sep 29, 2010 20:02 |
|
^^^^^ put your implementation in the header. It can't get instantiated from the .cpp And on an unrelated note: Ugg boots posted:
To elaborate, I am pretty sure you can't accurately represent numbers as simple as 0.10 (e.g. 10 cents) in (binary) floating point.
|
# ¿ Oct 1, 2010 01:37 |
|
Ledneh posted:Another question on the Boehm-Demers-Weiser GC. Is there some magic incantation I have to perform to make datain STL containers traceable (if not collectable)? In my test code so far I'm getting objects deleted prematurely everywhere, seemingly becauseit isn't tracking pointers stored in STL maps. IIRC, You need to get it to use GC_alloc for memory. Hopefully it provides an allocator...
|
# ¿ Oct 1, 2010 03:47 |
|
Lord Flashheart posted:Crossposted from the general programming questions thread: You're sending stuff after the server sent Connection: close. If it does that, you should (I think it actually is a SHOULD...) disconnect and open a new connection. Edit: actually, it's stronger than that; it's a MUST NOT: RFC 2616/8.1.2 posted:Persistent connections provide a mechanism by which a client and a OddObserver fucked around with this message at 09:15 on Oct 12, 2010 |
# ¿ Oct 12, 2010 09:10 |
|
Mopp posted:Yes, I'm doing this according to instructions and were told to use pointers. Shouldn't the constructor still be called? You never create the object. It's an uninitialized pointer pointing to some (sorta) random location (which may not even be) in memory.
|
# ¿ Oct 12, 2010 20:40 |
|
DeciusMagnus posted:This deletes the current b every iteration. Your way was deleting after the for loop was done, which means you were deleting null. It also accesses the nextBlock field of the just deleted one.
|
# ¿ Oct 15, 2010 19:48 |
|
Frequently impossible. More specifically, it depends on whether they use the same C++ ABI (Application Binary Interface --- which specifies how function names are encoded and layout of things like objects and vtables). For a long time basically everyone's scheme was different --- even different gcc versions were incompatible. There are perhaps a few more compatibilities now: both g++ >= 3.2 and some other Unix-friendly compilers like Intel's use the same ABI that was cooperatively designed for Itanium, but there is still a lot more that's different than that's same. (Also, I am not 100% sure of how the runtime library stuff is supposed to work when mixing compilers...) It -seems- that Sun CC is incompatible, but luckily the difference appears to be huge --- you'll likely just get tons of link errors if you try. Edit: if you want to know more about how an ABI looks, here is what g++ uses: http://www.codesourcery.com/public/cxx-abi/abi.html There is also of course an ABI for C that this builds on. Those are usually pretty much compatible since they're much simpler, but sometimes problems still crop in with stuff like SSE and whatnot. OddObserver fucked around with this message at 04:50 on Oct 23, 2010 |
# ¿ Oct 23, 2010 04:47 |
|
If you're on Linux or OS X use valgrind's Massif tool. Edit: and for non-initialized variables, its default Memcheck tool. It's also generally not true that debug builds do any special initialization (though some debug version of malloc fill fresh memory with known patterns). Edit #2: It might honestly be worth the effort to try building it under Linux to just run Valgrind. There is some chance it wouldn't be much work, and if you don't have a Linux system it's easy enough to just use a LiveCD. OddObserver fucked around with this message at 04:12 on Oct 24, 2010 |
# ¿ Oct 24, 2010 04:09 |
|
Actually Xlib is pretty simple (and similar, to Win32, really) for most of the basic things, too --- creating windows, drawing things, etc (though it's somewhat complicated by having both modern and obsoleted ways of doing things). There are some things, however, that are indeed pretty complex --- basically anything that involves interaction between different clients, in particular clipboard and drag-and-drop, requires implementing protocols from some lower-level primitives, and can get pretty messy. Oh, and X11/Xlib doesn't actually provide any actual widgets itself, which is sort of a big deal for actual applications (but not so much if you just want to play around and see the basics of how things work).
|
# ¿ Nov 23, 2010 07:34 |
|
FlyingDodo posted:Say I have a tree and I want to be able to get something from the tree by getting a pointer/reference to an object in it, not a copy. Is there a way to prevent the objects from being modified? I know I could use a const pointer or reference but its still possible to cast it as a plain old pointer and then change the data the pointer is pointing at. This is bad because the object would no longer make sense in the place it is in the tree. As stated? No (modulo some crazy stuff like mprotect if the object is meant to be entirely readonly). But as an alternative, you could make use of a copy-on-write type to get a similar effect, though at cost of some refcount thrashing.
|
# ¿ Nov 25, 2010 17:09 |
|
http://www.parashift.com/c++-faq-lite/templates.html#faq-35.18
|
# ¿ Jan 24, 2011 13:42 |
|
You need to say 'typename MyClass<_Ty>::MyFooTest' when referring to such a type in templated contexts.
|
# ¿ Feb 12, 2011 05:16 |
|
Add template<typename _T> before the void. Also you really want to pass in vectors by const reference; passing them by value is O(n).
|
# ¿ Feb 21, 2011 17:57 |
|
roomforthetuna posted:Not entirely a C++ question, but this seems like a good thread for it - is there a quick way to test the dynamic linking of a Linux "shared object" file, that I could use in a Makefile? As it is, if I accidentally try to use a function within the .so that the main program has available but the .so does not, the first I know of it is when I run the program and get: ldd -r seems to be that, though I am too lazy to actually try.
|
# ¿ Mar 4, 2011 05:58 |
|
Pass a pointer (or a reference).
|
# ¿ Apr 10, 2011 23:17 |
|
Rocko Bonaparte posted:I have been compelled to write some Python wrappers for some code I've been using. This has been slow-going for awhile but I am slowly starting to wrap my head around the Boost Python wrappers. Where I am stuck is how I could wrap bit fields. I actually didn't even know about bit fields until just now. The Boost Python bindings work with references to the properties or functions being wrapped, but one cannot take a reference to a bit field according to what I know of C++. Why not just add accessor functions and wrap those?
|
# ¿ May 16, 2011 12:43 |
|
tractor fanatic posted:
I think abstract::test(int) gets hidden due to having overloads in a subclass.
|
# ¿ Jul 10, 2011 01:09 |
|
Less educational but easier: just use popen() (and pclose()).
|
# ¿ Oct 6, 2011 21:53 |
|
.. And it's principal and not principle.
|
# ¿ Oct 21, 2011 03:25 |
|
Also, vec<float,3> a(); doesn't do what you think it does. It actually declares a function!
|
# ¿ Dec 18, 2011 08:41 |
|
tractor fanatic posted:I have a thread which checks if a bool is set, and if it is, calls a function through a pointer. Once set, neither the bool nor the pointer will change for the lifetime of the thread. Another thread will set the pointer and then set the bool. I don't care about the case where the pointer has been set but the bool is not. Are there any race conditions I haven't thought of, and is it a horror to just mark both the bool and the pointer as volatile, ignoring any other threading structures? You need memory barriers --- otherwise the write to the pointer may become visible -after- the write to the bool in the reading thread.
|
# ¿ Jan 4, 2012 16:21 |
|
Where does the null termination come from?
|
# ¿ Jan 17, 2012 06:59 |
|
if you can use ssh, you may e able to use scp or sftp.
|
# ¿ Feb 28, 2012 00:39 |
|
For a really nice POSIX reference, there is always the source, e.g.: http://pubs.opengroup.org/onlinepubs/007904975/functions/write.html Sometimes it even has historical and rationale discussions...
|
# ¿ May 16, 2012 13:42 |
|
If you are on an OS that supports it, valgrind. In that case, of course, you should be able to tweak build flags beyond Debug/release to get debug info in there. Also, --gtest-filter will let you run a subset of tests
|
# ¿ Jun 30, 2012 04:37 |
|
I think it's correct behavior, assuming this is C++, and not some typedef. bool's are permitted to behave as neither true nor false if you don't use them in a proper, well-defined, typesafe way (the standard gives an example of an uninitialized bool); and this is clearly doing weird stuff since there is nothing that says that true and false have to be represented in a certain way (in particular, sizeof(bool) need not be 1); merely that they convert to and from ints in a certain way.
|
# ¿ Aug 7, 2012 02:14 |
|
That'd likely be because you're passing in a pointer to a local to the thread start function. Don't do that --- by the time the thread is running, the variable may already be out of scope, with its stack space used for something else (like the instance of FD of the next iteration).
|
# ¿ Sep 17, 2012 04:53 |
|
Vanadium posted:Fix the API. Well, that's one way to learn ;-) Sometimes -fpermissive helps a bit, though it's usually for stuff that's way older than 4.1.2.
|
# ¿ Nov 23, 2012 17:55 |
|
Vanadium posted:But cpp processes definitions and does the whole substitution thing, it doesn't output the definitions again. gcc has -E -dM which prints defined macros out, see: http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Preprocessor-Options.html#index-dM-972 (Though I don't see the connection with bindings)
|
# ¿ Nov 24, 2012 02:25 |
|
Oh, std::swap is now written in terms of std::move, isn't it?
|
# ¿ Apr 11, 2013 02:55 |
|
Ciaphas posted:I've got some questions about creating and linking libraries. 4.7 and 4.8 will work as well (at least as long as you don't turn on C++11 mode, not sure of the current state of that). Basically all recent g++ versions are compatible (modulo bugs) but might require a libstdc++ at least as new as the version you've compiled against to run. quote:- What about libraries compiled in C? Discounting target processor, is use of them still restricted to the compiler they were made with? Basically generally inter-operable unless you hit weird spots, and again, you might run into trouble if you run against an older glibc version than you built against. Edit: also, the real advantage of dynamic libraries is when tons of apps use the same library --- you get to share most of the code/data memory for it between different processes, which is nice. OddObserver fucked around with this message at 05:16 on May 2, 2013 |
# ¿ May 2, 2013 05:11 |
|
I wonder why they didn't just make "only public POD data" (aka compatible with a C struct) a special case?
|
# ¿ Sep 26, 2013 04:27 |
|
GrumpyDoctor posted:Does changing it to vec.end() shut Coverity up? Surely they're the same for an empty vector, considering what a standard loop over range looks like?
|
# ¿ Oct 24, 2013 02:40 |
|
Suspicious Dish posted:It's not like strlcpy is any less broken. What should you use instead? Well, the conversation that inspired it probably calls for strdup anyway.
|
# ¿ Sep 17, 2014 06:07 |
|
|
# ¿ May 17, 2024 10:20 |
|
Mr. Crow posted:I'm learning gtest and c++ and can't wrap my head around how to do this, any guidance? I am not sure I really understand your question, but TYPED_TEST and TYPED_TEST_CASE may be of use. https://code.google.com/p/googletest/wiki/AdvancedGuide#Typed_Tests (Or alternatively TYPED_TEST_P)
|
# ¿ Oct 11, 2014 02:27 |