« first day (663 days earlier)      last day (4302 days later) » 

4:00 PM
@rubenvb By design, isn’t it? The whole rationale behind GCC’s architecture is unfriendly
 
People are stupid enough to the point of transliterating HTML (that's   in Greek letters).
 
@KonradRudolph LOL. Yup. And I can understand the codebase, just not fix my problem... llvm.org/bugs/show_bug.cgi?id=13565
 
Thankyou. And if I reverse it, and I tell the enum first number is Hex, can it automatically give all other values as HEX? thank you man ! — Anders Lind 3 mins ago
 
Someone doesn't know what a number is.
I find that sad.
 
@rubenvb Why are they shipping a <intttypes.h> incompatible with the compiler?
Shouldn't that be in their test suite?
 
4:04 PM
@ecatmur inttypes.h is a C header, is it not?
 
Clang doesn't provide C headers, duh.
And Windows is unused by the main (Apple) devs, duh.
 
@rubenvb Erm, shouldn't it pack it for C++?
 
@R.MartinhoFernandes Reminds me of some bit shifting question we once asked an interview candidate at work. She said the result of right shifting 0x1234 by 1 was 0x0123
 
Xeo
Manual bitshifting on non-binary numbers is hard :s
 
4:05 PM
@R.MartinhoFernandes well, it's also a libstdc++ issue
 
Xeo
Unless you convert them, of course
 
In the context of a C course for novices who have experience in Java, do you guys think it would be useful to show them how to simulate OO polymorphism in C? I have one additional day compared to last year, and I'm thinking about useful ways to fill it. "Useful" means "It's done in practice, and students are likely to see code doing just that."
 
@R.MartinhoFernandes wut? no..
 
@rubenvb Why not?
 
@Xeo It is, but that wasn't the question anyway, she was debugging some other problem
 
4:06 PM
The C++ standard includes <inttypes.h> (and <cinttypes> too).
 
Xeo
Clang doesn't ship with any library
 
Clang doesn't provide a C++ library
 
Ah, oh. Nevermind.
 
I make it use GCC's libstdc++, which works with a very minor fix to its headers.
 
@R.MartinhoFernandes Never heard of that one, sure you don't mean stdint.h?
 
4:07 PM
I thought you were saying it shipped everything else except that.
 
but that's completely beside the issue.
 
Xeo
The most annoying one being the type_info one
 
@FredOverflow No, I mean what I wrote :P
 
@R.MartinhoFernandes Of course, robots don't make mistakes.
 
inttypes.h includes stdint.h.
 
4:08 PM
@R.MartinhoFernandes is that guaranteed? You can duplicate definitions if you really really want to.
 
@rubenvb You can't because the headers are guarded.
 
@rubenvb so "%I64d" is some weird Microsoft extension?
 
I don't understand what you are trying to say...
 
Why not just use "%lld"?
 
ugh
If I have
 
4:10 PM
@rubenvb Standard headers are idempotent. Including them more than once has no effects (except for cassert and assert.h).
 
@ecatmur cross-platformness.
 
@ecatmur Probably for __int64
 
@R.MartinhoFernandes What's the problem with cassert?
 
but nobody in his right mind would use printf or anything like that
 
@R.MartinhoFernandes yeah, I know that. I just don't see why you're saying this.
 
4:11 PM
@FredOverflow You can defined/undefined NDEBUG and reinclude it.
@rubenvb There's no way to get duplicate definitions.
Dammit, I need to pay more attention when reading.
 
Three-star programmer alert:
0
Q: how to free correctly the pointers

polslinuxThis is a function that i've written: uint32_t file_list(char *path, char ***ls){ DIR *dp; //uint32_t i; struct stat fileStat; struct dirent *ep = NULL; uint32_t len, count = 0; int file = 0; *ls = NULL; dp = opendir (path); if(dp == NULL){ fprintf(stderr, "no dir: %s\n",...

We got ourselves a badass here.
 
@rubenvb Now to answer what you actually wrote... Yes, it's guaranteed.
 
236
Q: The Definitive C Book Guide and List

lillqTo follow the example of The Definitive C++ Book Guide and List for C Books here is a wiki post for organization. A tag search for "C" and "Books" returns no complete book list results as of writing this question. That search is here. This post is to providing QUALITY books and an approximate ...

 
@ecatmur "We got ourselves a moron here." FTFY.
3
 
Hm, never seen any of the C books listed under "beginner", but the first one is from Prata, so I fear the worst. Can you recommend a C primer?
 
4:14 PM
@ecatmur I'll just run.
 
@R.MartinhoFernandes you can guard each duplicate definition, windows headers are nefarious for that.
I'm just saying it's possible, not that it happens in practice.
 
@DeadMG with the unique_ptr, can I also use the assignment, (and then reset), when I need to destroy and recreate the buffer?
 
There's been a third attempt at a boost fiber library. It has finally made it into the beta :)
 
@melak47 unique_ptr is unique_ptr. What's the confusion?
 
I don't fibers. I want async/await.
 
4:15 PM
@Drise yeah, that would be a problem.
 
I bruised my finger. It's the irritating.
 
@MooingDuck You may have fun with this. ideone.com/HODYj
 
@DeadMG say I want to resize the buffer, I need to release the previous buffer
 
@Drise what about it?
 
Ugh, new and delete.
 
4:16 PM
How do I make it a happy function again?
 
@melak47 It's a smart pointer, not a "Half the time I can't be arsed" pointer.
 
@DeadMG do I just uniqe_ptr.release() ?
@DeadMG huh?
 
@melak47 I'm not going to personally tutor you on every single member function unique_ptr offers.
 
It has been said that the price difference between the C89 standard (approx $130) and "The Annotated C Standard" (approx $30) reflects the added value of the annotations. — Bart van Ingen Schenau Nov 1 '10 at 20:29
2
lol
 
the whole goddamn point of a "smart" pointer is that if it's contents are non-null then it will always destroy them.
 
4:17 PM
@melak47 I don't know what you're talking about, but unique_ptr.reset(new ptr) seems relevant.
 
so stop asking if every possible action requires you to manually delete it because they don't.
 
@melak47 reset it.
release is a last resort tool.
 
@R.MartinhoFernandes Boost.Task?
 
@DeadMG :S ok
 
@ecatmur Nope, not the same.
 
4:18 PM
@Drise can't be done without altering the function.
 
What I'm talking about requires AST transformation.
 
@MooingDuck How do I alter the function?
 
@kbok got a link?
 
@Drise when should it become happy again? Every other time?
 
@MooingDuck No, I want to it be sad only for the object's lifetime.
 
4:20 PM
@R.MartinhoFernandes but I don't have the new pointer yet. I only get that once I do CreateBuffer(.., &pointer) again
 
@Drise make MyBool a nonstatic member then
 
@MooingDuck Meh. Do I have to?
 
@melak47 Then reset() it (no arguments).
 
@Drise static is global. Everything that's per-object is a member.
@Drise yes. wait, is there only one copy of the object alive at a time guaranteed?
 
4:21 PM
melak
 
@kbok ah, it's Boost.Context now. Thanks.
 
@MooingDuck Yea.... I think.
 
unique_ptr is not a baby. It will always manage the internal pointer for you, unless you release().
so stop worrying about it
 
Did anybody recently build qt5?
 
@Drise if and only if that is guaranteed, you can make it a static member, and reset it in the constructor/destructor.
 
4:22 PM
@MooingDuck Meh. I just need to make it a member.
 
@DeadMG I think you're completely misunderstanding his question
 
his question seems to be "For situation X, do I need to manually handle the resource?" for 999999 situations X.
even though I already explained that the answer is no for every situation X except calling release().
 
@DeadMG I just wasn't sure if I can just let D3D plug a new pointer in there
 
@melak47 so reset it with the result of CreateBuffer, and don't bother freeing it beforehand.
 
@melak47 The mechanism is perfectly and completely safe.
as long as you never call release(), you can never make a mistake.
 
4:24 PM
@DeadMG ok..
 
well, except accessing null, of course.
 
How did you end up overloading operator&?
 
@R.MartinhoFernandes It's for smoother interoperation with COM functions.
 
@R.MartinhoFernandes pastebin.com/D4CAJpXa
 
I get that, but how did you grab the internal pointer?
 
4:25 PM
4
Q: static variable vs. member

AnonymousIf you have data for a class that will be modified and needs to be retained throughout the program, but is only used in one member function, is it preferred to make that variable a local static variable of the routine that it is in or make it a member of the class?

 
@R.MartinhoFernandes I didn't. Proxy object.
 
@R.MartinhoFernandes It's pretty smooth.
 
@melak47 why do you have a pointer to a unique_ptr? and a T**
 
@MooingDuck COM APIs crap.
 
4:28 PM
@MooingDuck because @DeadMG used magic :p
 
2 hours ago, by R. Martinho Fernandes
@rubenvb They want it to pass to some crap API that takes pointers by pointer as output parameters.
 
@melak47 the more I read this the more magic I see.
 
@DeadMG It would be smooth if its name weren't longer than mine.
 
@R.MartinhoFernandes Who cares? Implementation detail.
 
@R.MartinhoFernandes you mena PointerToPointerToUniquePointer?
 
4:29 PM
Note to self: next time you want to make an edit, make the edit before pressing enter.
 
@R.MartinhoFernandes :D
 
shared_ptr<ITexture2D> mti;
.......
resized function
.......
mti = mwind->CreateTexture2D(mwind->Width,mwind->Height);
Why does this case a memory leak when I recursively assign to the shared_ptr?
 
@melak47 the magic appears broken though
 
Shouldn't the = operator decrement the old reference count
and free the resource when it's reference count is 0?
 
AFAIK, shared_ptr doesn't have an implicit conversion constructor.
 
4:31 PM
@MooingDuck It's not broken.
 
CreateTexture2D returns a shared_ptr<ITexture2D>
 
so no implicit conversion is needed
Why isn't the resource being freed?
 
@DeadMG operator T**() always returns a pointer to a NULL pointer.
 
@IDWMaster ....huuhh? what are you doing...CreateTexture2D returns a HRESULT
 
4:32 PM
@MooingDuck That's not broken.
 
@MooingDuck It's meant for an out parameter.
 
@DeadMG I know nothing of COM, so it's possible
 
@melak47 I'm using a different library than what you're thinking of
 
@R.MartinhoFernandes oh, I see now. Got it.
 
Not the standard DirectX library
 
4:33 PM
@IDWMaster oh. ok then :)
 
Here's some more context
shared_ptr<IVertexBuffer> vertbuffer;
	shared_ptr<ITexture2D> mti;
	BGRAPixel* bgrapixels = (BGRAPixel*)mtils->IDWALLOC(sizeof(BGRAPixel)*640*480);

	mwind->Run([&]() {
	//Render loop here
		mwind->Clear(0,0,0,0);

		if(firstrender) {
			firstrender = false;
			mti = mwind->CreateTexture2D(mwind->Width,mwind->Height);
			shared_ptr<I2DRenderSurface> surface = mwind->GetRenderSurfaceFromTexture(mti);
			surface->Lock();
			surface->Clear();
			shared_ptr<IBrush> mbrush = surface->CreateSolidColorBrush(1,0,0,1);
Creates a memory leak if I frequently resize the window
Because the texture is not being freed
 
well
to put this bluntly
 
@IDWMaster doesn't shared_ptr use delete
 
what the hell do you expect from us?
 
@DeadMG I still find it wierd that operator& on a ComPtr gives you a type that converts to a pointer to a null pointer.
 
4:34 PM
but you used some alloc?
nvm
 
Doesn't mti = NULL require an implicit conversion?
 
@MooingDuck Pointer-to-pointer is used to receive pointers, not give them. They're out parameters.
 
@IDWMaster (BGRAPixel*)mtils->IDWALLOC(sizeof(BGRAPixel)*640*480); looks like the only leakable thing to my eye.
 
Or is there a standard library that already defines NULL as nullptr?
 
@R.MartinhoFernandes No. Standard forbids it.
 
4:36 PM
@melak47 I'm using a custom deleter
 
@DeadMG Erm. No, it doesn't.
 
I know where the memory leak is
 
@DeadMG and no function could conceivably want to read the object and sometimes reallocate it?
 
@R.MartinhoFernandes why are we not using nullptr?
 
It's caused by the texture not being released when the window is resized
My question is why?
 
4:37 PM
It says it's a null pointer constant, which nullptr is.
 
@R.MartinhoFernandes I think it does
 
@IDWMaster How would we know? You're using a library with which absolutely none of us would have any experience.
 
@Drise Don't ask me.
 
The issue is that the shared_ptr isn't calling the destructor, and I'm just wondering why it's fixed when I manually call the constructor, and free function
 
@R.MartinhoFernandes Pretty sure that it does. They considered #define NULL nullptr but rejected it because they found abominations like char c = NULL; all over old codebases.
or maybe they just rejected forcing implementations to change.
 
4:38 PM
@IDWMaster there must still be a reference somewhere.
 
@IDW
 
@DeadMG Yes, the implementors decided not to do it to avoid breaking code.
The standard allows it.
@DeadMG Exactly.
 
@fadedreamz What?
 
every day I come to work, a different subset of my projects fails to compile because they're including headers from the wrong folder.
 
@IDWMaster as @MooingDuck said, there must be some reference somewhere
 
4:40 PM
So, I have no idea what's going on. I doubt mti = NULL compiles.
@MooingDuck You really need to shoot someone.
 
NULL is a null pointer constant.
That means it is either 0 or nullptr.
 
@R.MartinhoFernandes It does actually
I can remove that line
and I still get the same result
 
isn't NULL --> #define NULL (void *)0
 
@ecatmur we know that, but you can't assign it to a shared_ptr
 
@fadedreamz No, that one is explicitly forbidden.
 
4:41 PM
:4874327
 
My gravatar-thingy is about to change.
 
@fadedreamz certainly not.
 
NULL cannot be a pointer. Confusing? Suck it up, that's C++.
 
Do you guys want me to find a portrait?
 
Well; it compiles!
 
4:42 PM
but you say it doesn't work like you want it to :p
 
@LucDanton A portrait of what?
 
@IDWMaster the fact that that compiles is probably related to your bug.
 
no according to C its #define
 
Null pointer constants are either an integral constant with value 0 or a prvalue of type nullptr_t.
 
but new standard defines the nullptr type
 
4:42 PM
@R.MartinhoFernandes Or icon.
 
@LucDanton animal
 
try nullptr_t with old compiler --> compile error
 
nullptr is a nullable pointer. nullptr is not a pointer.
The joy.
 
so, I was trying to debug eapol_test from wpa_supplicant for RADIUS (EAP-TLS) testing in linux, but failed to import the eapol_test into an existing Makefile project (eclipse)
where can I find the Makefile if I open a project and then import the file?
in eclipse
 
Xeo
13
Q: Conditional compile-time inclusion/exclusion of code based on template argument(s)?

XeoConsider the following class, with the inner struct Y being used as a type, eg. in templates, later on: template<int I> class X{ template<class T1> struct Y{}; template<class T1, class T2> struct Y{}; }; Now, this example will obviously not compile, with the error th...

Yay, another popular question badge
 
4:48 PM
Hmm
Memory leak must be in library
 
I saw an interesting video on MSDN (channel 9)
the topic was template meta programming
 
TMP is cool.
 
yes
 
Well, except when you're labelled a "hobbyist template wanker". That's not cool.
 
@R.MartinhoFernandes Let's not oversell.
 
4:49 PM
I saw an interesting video on xHamster.
 
I liked it, but never had the chance to do
 
@DeadMG how does your struct magic work, anyway? I give D3D the pointer to t_ptr in the struct, so that's where it puts the result...but then how does it ever end up in the uniqe_ptr?
 
@LucDanton Et tu Luc?
 
@RadekSlupik \m/
 
@R.MartinhoFernandes The syntax does go in the way.
 
4:50 PM
@melak47 The destructor puts it back.
 
@melak47 The destructor performs the work.
 
@LucDanton I can't disagree.
 
@DeadMG ahhh
 
Template Haskell. <3
 
that explains why I can just let D3D put in a new pointer. it just goes in a temporary pointer and then regular assignment.
 
4:52 PM
Weird, gcc-4.7.1 is compiling shared_ptr<T> = 0
 
Pretty sure it shouldn't.
 
inspects headers
 
Xeo
"sizeof(word)" -- nonononononoNO! — Xeo 1 min ago
@Xeo care to elaborate? — ewok 42 secs ago
If he doesn't see the problem, I somehow don't want to elaborate..
 
      template<typename _Tp1>
	explicit shared_ptr(_Tp1* __p)
        : __shared_ptr<_Tp>(__p) { }
 
Xeo
4:53 PM
@R.MartinhoFernandes assignment op
 
Oh.
No such thing standard.
 
soo many underscores.. my brain just doesn't read that nicely
 
No such thing in libstdc++ either.
 
Xeo
I don't see why shared_ptr<T> p; p = 0; should be ill-formed
 
@Collin It's straight from the stdlib implementation :S
@Xeo Because there's no implicit conversion.
 
Xeo
4:55 PM
Huh?
 
@R.MartinhoFernandes Yeah, I've seen it before, just every time I look at that source I get reminded of it
 
@Xeo 0 is an integer, not an address.
 
Why would you want a null shared_ptr anyway.
 
Worse: std::shared_ptr<int> p = 0; compiles.
 
@Xeo The same reason shared_ptr<T> p = 0; should be ill-formed.
 
4:56 PM
It's an explicit constructor.
 
I don't want int* p = &blah; f(p); to silently make a shared_ptr.
 
Xeo
@R.MartinhoFernandes What does that have to do with the assignment op?
 
@Xeo The assignment op is making an implicit conversion.
 
lol, you're the one that brought up assignment.
 
@ecatmur can you come up with a case where that would be a bad thing?
 
4:57 PM
@MooingDuck Is that relevant?
 
@LucDanton It was an assignment in the first instance.
 
Xeo
Derp, nvm
 
Yup, void f(std::shared_ptr<int>); f(0); compiles. Ick.
 
If I have a non-owning pointer I don't want the compiler to transfer the ownership it doesn't hold behind my back.
 
Xeo
@ecatmur, does f((int*)0) compile?
If it doesn't, I have a theory
 
4:59 PM
@Xeo Doesn't with 4.8.
 
4.8 is out?
 

« first day (663 days earlier)      last day (4302 days later) »