« first day (475 days earlier)      last day (4466 days later) » 

9:00 AM
dunno, maybe google know answer
 
The underscore came by, "deprecated" all POSIX functions and replaced them with supposedly "ISO C++ conformant" underscored versions.
C++ has no _open.
 
but it does reserve _name for the Standard lib
 
But POSIX functions are not part of the standard library.
 
I believe the specific wording reserves them for the implementation's use, in general
 
anyway I don't want to meet #define open in CRT headers
 
9:04 AM
open is in <fcntl.h> or something.
When you #include that, it's because you want open.
 
no, it's because some header-only library wants it
 
<fcntl.h> is POSIX header. It's not part of the C library.
Well @Tin, I guess you'll have to use #if _WIN32 to pick between _stat and stat... :S
And it's not like <windows.h> is a good citizen anyway.
 
oh yaeh
the Windows header is disgusting
 
Tin
@RMartinhoFernandes, sth. like this, right?
#if defined(_WIN32) || defined(WIN32)
#define _stat((path),(buf)) stat((path),(buf))
#endif
 
no
not like that at all
 
9:11 AM
I'd make it a function.
inline int stat(const char *path, struct stat *buf) { return _stat(path, buf); }
 
Tin
@DeadMG, which would be the correct way then? what's wrong by doing it in this way?
 
uh, it's an un-scoped macro
 
@Tin It's the wrong way around.
 
that's terrible in about every way imaginable
 
@Tin Macros are dangerous. Avoid them if you can.
 
9:13 AM
it should be a function in an appropriate namespace who's implementation delegates to the correct function dependin on the macro definition
 
Tin
thanks for the advice
but, how could i then choose this function, when the code is running in Windows? where does the #if _WIN32 comes?
 
also, don't use _WIN32, use _MSC_VER
 
Isn't that to detect the compiler?
 
it's VC++, not win32 stuff
 
9:16 AM
struct stat is such a stupid name for a type used in a function named stat. People in those days just named things after snorting coke.
2
 
or mingw uses _stat or not defines _WIN32 ?
 
MinGW defines _WIN32. I don't know about _stat.
 
Tin
@DeadMG, thanks for the code snippet! why do I need an extra namespace? also, which is the difference between WIN32 or _WIN32. in your if condition, should i need to check both WIN32 and _WIN32?
 
you need a namespace because non-namespaced code is really bad
 
9:18 AM
There are about three gazillion macros like that.
 
there is no WIN32 macro
 
and I've no idea, don't remember about WIN32 or _WIN32
 
4
Q: Which Cross Platform Preprocessor Defines? (__WIN32__ or __WIN32 or WIN32 )?

mathI often see __WIN32, WIN32 or __WIN32__. I assume that this depends on the used preprocessor (either one from visual studio, or gcc etc). Do I now have to check first for os and then for the used compiler? We are using here G++ 4.4.x, Visual Studio 2008 and Xcode (which I assume is a gcc again) ...

Seems only _WIN32 is documented, but that never stopped people.
 
Tin
@Abyx, so this should be then the correct way? pastebin.com/6GaKKyas
@DeadMG, I also agree on namespaces, I thought, I needed an additional namespace only for this function :-)
 
9:22 AM
@Tin you can collapse defined(_WIN32) || defined(_WIN64) to defined(_WIN32)
 
aha
 
Tin
@Abyx, and what defined(_MSC_VER), is that correct? => #if defined(_WIN32) || defined(_MSC_VER)
 
as well as remove defined(_MSC_VER), I dunno if mingw uses _stat
 
Tin
@Abyx, ok, so I'll leave then everything to be the same as @DeadMG initially proposed
thanks a lot guys!
 
lol #define _stat _stat32
 
9:25 AM
$ grep "_stat\s*(" /win/MinGW/include/*.h
/win/MinGW/include/bfd.h:extern int bfd_stat (bfd *, struct stat *);
 
as I said, with stat they'd #defined it
 
Yep, MinGW uses _stat... :S
Wait, bad file.
It seems to define _wstat and a host of others, but not _stat.
Gosh, this is a mess.
 
@Tin you can try #if defined(_stat) =)
 
It does define struct _stat
 
huh? #define struct _stat ?
 
9:27 AM
No, struct _stat { blah blah };
 
so, I like the GetFileAttributes function. That ugly long WinAPI name.
 
Well, the only way to know for sure is to try it.
Found another singleton in Boost. Yuck.
 
there is three or four of them, AFAIK
but they are not true singletons
 
Ah, found it!
/win/MinGW/include/sys/stat.h:_CRTIMP int __cdecl __MINGW_NOTHROW       _stat (const char*, struct _stat*);
 
Tin
after adding the function (http://pastebin.com/cyQmMa8Y), i get the following compiler error:
error: redefinition of ‘int stat(const char*, stat*)’
/usr/include/sys/stat.h:434: error: ‘int stat(const char*, stat*)’ previously defined here
 
sbi
9:35 AM
Is @Xeo still around?
 
@Tin You can't define it in the global namespace, as there is already one (the original one)
@sbi Only if he woke up already.
 
sbi
@RMartinhoFernandes Well, he said good night 8hrs ago.
 
Tin
@RMartinhoFernandes, thanks! I added the namespace and it compiles now
 
@Tin See, that's exactly why it's not a good idea to put things in the global namespace :)
 
now I hate 7z code. with its cool #includes
#include "Common/MyException.h"
#include "Common/StdOutStream.h"

#include "Windows/Error.h"

#include "../Common/ArchiveCommandLine.h"
#include "../Common/ExitCode.h"

#include "ConsoleClose.h"
 
Tin
9:39 AM
@RMartinhoFernandes :-)
 
@sbi That reminds me I said I was going to buy food two hours ago... afk
 
2
Q: As the delete operator deallocates memory, why do I need a destructor?

Anisha KaulFrom c++ FAQ: http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.9 Remember: delete p does two things: it calls the destructor and it deallocates the memory. If delete deallocates the memory, then what's the need of the destructor here?

new comment at the end of the question
 
When you move from a vector, does the old vector perform any allocations?
Or is it OK for it not to have any valid internal buffer at all?
 
It's okay to have a null pointer if the rest of the code (especially the destructor) can deal with it.
 
I love this guy I am working with, more or less every function he write has the same format logOnEnter(); try{ // all code here} finally { // bit more code } logOnExit();
why is everything inside one giant try block? NOTHING YOU CALL THROWS ERRORS
 
9:51 AM
@thecoshman More importantly, what strange language is that?
 
Java :P
 
Does Java have function-try-blocks, too?
 
you happier now I have semi-colons :P
AFAIK it doesn't, I just didn't think to type the ';' in the example, but just sneaked them in
Perhaps I got the wrong end of the stick, but are you not supposed to keep try blocks to just what can fail?
or more specifically, what can throw errors you need to handle
 
if you have a pool of objects that are being reused, would you make the bool that says whether the object is being recycled or can be put back in the pool part of the objects itself or would you make a std::map<bool, object> instead?
 
but if you used a map, how would you get your next free object?
 
9:58 AM
@thecoshman You cannot always know if some code could fail.
 
it's more maintainable
 
@KerrekSB Do function-try-blocks have special semantics, or are they just syntactic sugar for wrapping the function body in a single try-catch?
 
@TonyTheLion Shouldn't that be a multimap?
 
@TonyTheLion A std::map<bool, object> cannot hold more than two entries. Doesn't sound terribly useful to me.
 
@FredOverflow that's why I added specifically for code that throws
 
10:00 AM
@RMartinhoFernandes The scope is slightly different
Also they have a unique role in constructor initializer lists.
 
@thecoshman it can contain more then one pair of bool,object pairs
I'm not sure I"m following what you mean
 
but like @Fred said, if you key is a bool, then you only have two keys, true and false
thus you can only store two objects
 
@KerrekSB Oh, they can catch exceptions thrown from member initializers?
 
@TonyTheLion You probably want a std::map<object*, bool> instead.
 
@RMartinhoFernandes Sort of
 
10:02 AM
Also, it's annoying how now we can have "constructor initializer lists" and "initializer list constructors".
 
@thecoshman oh yes, valid point
@FredOverflow why pointers?
 
@KerrekSB I assume that you cannot swallow such an exception, as it would leave you with an invalid object. Is that the difference?
 
@RMartinhoFernandes Isn't that a member initializer list? I know the syntactic element is ctor-initializer or something, but nobody calls them "ctor initializer", right?
 
@TonyTheLion each pointer to an object (should) be a unique value, else you have the same object
 
@TonyTheLion Anyway, I'd wrap the object so that on construction you draw from a pool from free objects (use your favorite container, I used a list last time). The object instance/reference that is being used then is removed from the container ans well, stored in your instance (however you want that). Upon destruction instead of destroying the object you can place it back into the pool container.
 
10:03 AM
@FredOverflow Some people do.
 
@RMartinhoFernandes Yes. You always have to exit via an exception.
 
@TonyTheLion Pointers if the map should "know" the objects, not-pointers if the map should contain them.
 
@RMartinhoFernandes If you don't, there's an implicit throw;.
 
@TonyTheLion Anyway, the important part is that bool should be the value type instead of the key type :)
 
10:04 AM
ok
 
why not just have `std::array<std::vector<object>, 2>
or object*
 
using a map<object, bool> is rather nice
 
no, it isn't
 
@TonyTheLion Why do you think you need object pooling in the first place?
 
O(n) to find an object which is free?
 
10:07 AM
What kind of lookups will you perform? "Get me a free object" or "Tell me the state of this object"?
 
isn't map a O(log(n))?
 
not to find a specific value
 
Only if you search by key.
 
to find a specific key
 
this map will probably not have more than 10 objects at any given time
 
10:08 AM
Why do you need pooling at all then? 10 objects is nothing.
 
ah
well, because the objects manage hardware resources, so I don't want to create new objects all the time
a hardware resource disappears
but perhaps I'm silly
 
I see. Well, thread pools and database connection pools do make sense.
 
well, I'm not talking about threads/dbs. I'm talking about managing USB devices
and what I'm trying to do is when a USB connection is lost, I can remove the device from a list of active devices and move it to inactive devices. When a new connection is found, add it back to the active list
 
"remove the device from a list of" reminds of @DeadMG's pair of vectors somehow.
 
without disturbing operation of any active USB devices
however, I thought this was supposed to be simple to implement, but it seems to be getting more complicated all the time :(
 
10:12 AM
@RMartinhoFernandes I used the technique for visible and invisible objects in my renderer.
 
Can you show us the class of such a "USB device manager"?
 
because on top of everything else, the USB devices are talked to by another process, which I also have to manage
 
31
A: Why doesn't C++ have a garbage collector?

Brock WoolfI'll probably get voted down for this. It's a joke about C++ :D Q: Why doesn't C++ have Garbage Collection? A: Because then there would be nothing left.

jokes as answers?
 
@FredOverflow it's quite big, not sure if that's a good idea
 
they're deleted these days
I think they were permitted and now a few are left for "legacy compatibility" :P
 
10:15 AM
@TonyTheLion I meant the basic structure. Members, constructors, destructor, special copy functions.
 
Let's delete it!
Oh damn, it needs negative score.
 
try flagging it
 
@DeadMG Nah, I already have the badge. No need to flag for sport anymore.
 
10:17 AM
try { Standard("C++0A"); } finally { Standard("C++0B"); }
 
@FredOverflow well, here's the header
 
try {
    try {
        try {
            Standard("C++08");
        } finally {
            Standard("C++09");
        }
    } finally {
        Standard("C++0A");
    }
} finally {
    Standard("C++0B");
}
 
lol
 
@TonyTheLion pretty sure that violates the rule of three
 
so everytime it's final !!
 
10:21 AM
@FredOverflow meh, what did I forget :(
 
no, it doesn't
that's not a copy constructor
 
@TonyTheLion You have a destructor, but no copy constructor and copy assignment operator. At least hide them.
 
oh, true
 
right, so I made a private copy ctor and operator=
 
great
 
10:24 AM
do I have to implement them if they are private?
 
You don't, that's the trick.
 
You want to get a compiler error if someone tries to copy an object.
 
right
 
sbi
It's cold here.
 
10:25 AM
here too :(
 
lol
cold here too, heating doesn't work
freezing my ass off, and my brain too
meh
 
in order for that to be true, you'd have to have a brain to be frozen off :P
 
sbi
@TonyTheLion If the heating wouldn't work here, I'd be home. We had about -10°C this morning here. No way I'd stay in a room without heating.
 
@DeadMG yea I know, I'm brainless
@sbi meh it's -5.5 here
 
10:27 AM
@sbi If the heating didn't work ;)
 
outside that is
and inside it's 10 degrees
 
sbi
@FredOverflow Really? Is there a rule for this?
 
"If" does not match with "will" and "would".
 
sbi
@FredOverflow Oh, I hadn't known that. But then I know almost no rules for the English language.
 
wow
Argentina is seriously trying to provoke us over the Falklands
 
sbi
10:30 AM
@DeadMG You're in a time loop. That was in the 70s. Or was it the 80s?
 
and today, as well
apparently, they're calling us the colonialists
 
when 99% of the islanders want to be British and they want to take them
 
sbi
As world dictator, I will give sovereignty over the Falkland Islands/Las Malvinas to ... BANGLADESH!
 
and I'm like, WTF, apply logic plix
 
10:32 AM
Stross as a world dictator? Hmm.
 
sbi
@cstross @bradallen137 Blocked the spammer. So Brad is number 6000! With this many minions, world domination MUST soon lie within my grasp!
(He is talking about the number of his followers.)
 
I missed that.
Damn you, Twitter.
 
I'm starting to like him.
I mean, as a world dictator. I already like him as a writer.
Ruby is really silly: blog.bigbinary.com/2008/06/23/….
 
@RMartinhoFernandes Daily WTF submission right there
 
10:43 AM
I was really expecting something more... I'm not sure what I was excepting. But it certainly wasn't "In short Matz decided to have all the odd numbers reserved for numerical values."
 
> I was excepting :)
 
throw unknown();
 
sbi
> I'm not sure what I was excepting.
 
> Meta is, of course, the place where you go to discuss the place. Take a moment and think about what that means. Meta is for people who care so deeply about their community that they're willing to go one step further, to come together and spend even more of their time deciding how to maintain and govern it. So, in a nutshell, I was telling the people who loved Stack Overflow the most of all to basically … f**k off and go away
 
10:52 AM
@sbi So, I made a mistake. I get it. No need to keep repeating it.
 
Rumour has is, some one made a mistake a few minutes ago
 
has is? rofl. Rumour haz iz...
 
(╯°□°)╯︵ ┻━┻
 
@thecoshman With your keyboard layout issues, I'm surprised sometimes your messages seem intelligible
 
sbi
@RMartinhoFernandes But you made two mistakes! :b
 
10:55 AM
I may as well just give up trying to write properly ¬_¬
 
@sbi Are you fucking kidding me? That's not possible.
 
sbi
@thecoshman You mean you haven't so far? :b
 
There's nothing else wrong there.
 
From your perspectives, have I been getting better at spelling?
 
sbi
@RMartinhoFernandes I'm not telling. :b
 
10:57 AM
@RMartinhoFernandes I'm curious too, I didn't see it.
 
@sbi Ha, your mind games won't work.
 
@RMartinhoFernandes you started a sentence with 'But', which whilst not technically wrong is considered bad practice; which as far as I am concerned makes it wrong.
 
@thecoshman Sometimes I think so, but then you have a relapse. Or two, or three
 
You also had the full stop with in the quote, whilst it should have been after the closing of the quote
 
@thecoshman a dyslectic language pedant. lovely
 
10:59 AM
I believe that closing parentheses should come after the period.
 
@thecoshman The full stop is part of the quote.
 

« first day (475 days earlier)      last day (4466 days later) »