« first day (2118 days earlier)      last day (2813 days later) » 
00:00 - 16:0016:00 - 00:00

4:08 PM
Okay I need C++ design advice. I got a program that links against like 20 dlls for different hardware configurations, but only 3 at once. I used to control the hardware configuration with #includes and rebuild, but I'm considering switching to an xml configuration file. Not 100% sure if this is worth doing...
 
Ell
Eh
How did you control linking with includes?
 
#pragma comment(lib, "ahmcore.lib")
 
Ell
That's a #pragma ;)
 
But Boost does it!
 
@nwp There's a fundamental problem right now: although the compilers support modules, they haven't (as far as I know) produced module-based versions of the standard library and such. I suspect a lot more users are likely to jump on board after 1) there's more agreement on how they'll work, and 2) they can see the benefit in existing use.
 
4:14 PM
Don't look at me that way
 
Ell
are you using msbuild?
 
Yeah, but I don't know how to use msbuild
 
Ell
Well
Instead of doing your own XML thing
I would suggest learning some msbuild
Even if it means just using VS GUI to make targets and such
 
yeah but i cant have targets for all 20 choose 3 combinations
 
Ell
I agree
I'm sure msbuild is more intelligent than that
Disclaimer: I don't know how to use it either
 
4:20 PM
:-)
The real problem is that you can't /DELAYLOAD a dll with a #pragma
 
Ell
4:41 PM
I would just use your existing build system
no need to frankenstein it
 
But Frankenstein's monster had plug-n-lay capabilities.
 
Ell
groan
 
5:04 PM
Thousands of teenagers perk up at what they initially thought might have been "plug and get laid", but leave in anger and frustration when they realize the truth.
 
Ell
5:21 PM
hmm
I can't figure out how best to test some p2p networking code just on my local machine
meh I'll just forego everyone being a "host" for now
 
virtual machine or amazon ec2
 
Ell
so much effort :3
It's okay I've decided just to have one host for now anyway
 
you can implement a virtual network interface, for example
 
Ell
yeah
hmm
I'll investigate at a a later date
 
6:26 PM
@Borgleader
-4
Q: Hello, a noobs dilemma: should i stop learning c++ and go for something alse?

HappyNameIm very new to programming (i dont think i can call what i know programming) and just started to learn c++ alone on the internet. in the beginning i told myself "wow, this is not so hard like many people say" but now I feel like my head cant hold all of this information at once. I am learning now...

 
ADG
how to check which generic type has been passed in a template function
 
@ADG Why do you want to? Most cases of trying to check the type are mistakes. Either you want to specialize, or you want to check characteristics of the type (and, really, specializing should usually be on characteristics of the type as well, but...)
 
nwp
@ADG you are not supposed to care about that, but you can use std::is_same to check for various types
 
ADG
i am making a system of rooms
labs and lecture halls extend it
i want to read their info froma file but for labs and lecture halls, there are 1-2 more fields to read
so i was tryign to make a template function and by comparing T, read required file and read required no of members
 
nwp
6:42 PM
@ADG you should probably go here
 
ADG
hmm
thnx
its inactive
 
nwp
it becomes active when someone is there, here you will probably get kicked as soon as a room owner wakes up
 
I don't think we're that mean
 
ADG
np
 
import numpy as np
 
6:47 PM
@ADG Specialization would be the obvious way to go here.
@Mikhail As long as things are relatively slow at the moment, I certainly don't object (and I seem to be the only owner present right now...)
 
7:17 PM
Why does GDK have the worst documentation EVER :/
oh hi @Jerry @nwp
 
Ell
7:48 PM
git stash is so handy again
I very much like doing git add --patch, git stash --keep-index, (test) git commit ,git stash pop
I think I could do
git stash --patch --keep-index
(test)
git commit
git stash pop
very handy
anyway bed/work time for me
bye all
 
@thepiercingarrow The cardinality of the set of "worst documentation ever" is an uncountable infinity.
 
nwp
ѡ
no cheating
 
lol
@Ell bye
 
@nwp How dare you say such a thing in a place that's oriented (even slightly) toward programming. A great deal of programming is about finding effective ways to cheat.
 
nwp
8:08 PM
@JerryCoffin I don't know. You can cheat at benchmarks where you just divide the time your version took by 10, but that is not useful. And finding ways to solve a problem with minimum effort, for example by using a lib that just solves it isn't considered cheating.
what would be an example of a good cheating for you?
 
or just copying and pasting other people's code
 
8:24 PM
@nwp Good algorithms like binary search instead of linear search.
@Mikhail That may be cheating, but it's not about programming.
 
Yeah, my window is too small to read beyond 2 or three lines
 
@Mysticial Nothing related to PHP is about programming at all.
 
8:42 PM
In the context of PHP, "programming" is just an euphemism for damage control.
 
Yeah, all the smart people do CSS anyways
 
8:55 PM
Hmm, why can't we have try blocks without catch blocks?
 
Ell
What would it do?
 
@Mikhail Ask yourself that question and you shall get your answer.
 
@KatyTurNBC Gee @Reince cannot control a malignant narcissist? Your next meeting w/ Trump bring this w/ you. https://t.co/IGywPRZtgK
oh man. America
 
It would be short hand for try{something()} catch (...){//fuck it}
 
Ell
It would only encourage bad code
 
8:58 PM
In my work its sometimes impossible to know all the cases of failure
 
Ell
If you don't know the cause, how will you handle it?
 
default case
Try to connect to the hardware device, if something goes wrong return the simulated hardware device
Also why do we have #elif but no elseif
 
Ell
We have else if :3
 
I should write a letter to Bjarne
 
@Mikhail Try email. He usually responds within 24 hours.
 
9:11 PM
IDK, I think SMS might get a quicker response.
 
Do you have his mobile number?
 
99999 999999
 
I doubt he'd use a number that can't fit in a unsigned int.
 
@fredoverflow Bjarne's line about that: "When I was inventing C++, my goal was to make programming as easy as using a phone." [holds up his smart phone] "I guess I've succeeded. I don't know how to use my phone any more."
@Mikhail Because its lack would be much more annoying with the preprocessor, where we can't put the next if right next to the else. Worse, older preprocessors often didn't allow indentation (at all) so nested conditions became problematic very quickly.
 
9:25 PM
@JerryCoffin I thought it was using a TV.
 
herro
anyone here use GDK?
 
no
 
nwp
I wonder if we will get some un-documenting next year
 
@Puppy Not how I heard it, but I didn't see it in person, so I can't say which with any authority.
 
9:40 PM
the basic principle of the quote is the same either way
 
@Puppy Yup.
 
9:59 PM
@JerryCoffin Hey, do you know if there's a standard HRESULT value for a version mismatch?
 
@EtiennedeMartel No, not off the top of my head. Sorry.
For most stuff, it wouldn't apply: a different version is written as a separate interface, so somebody asking for IFoo0 will only ever get an IFoo0, and even if you have IFoo1, IFoo2, and IFoo3, their being a version mismatch won't matter (i.e., they won't get the later interface unless they ask for it).
(Assuming you're dealing with COM, of course).
 
We have an executable that returns HRESULTs as result codes.
 
Well what does _com_err give you
 
@EtiennedeMartel Not a COM thing, just a plain executable?
 
Well it does use COM eventually.
It's just that we felt that using HRESULTs for return values was convenient.
Basically it's a plugin loader and the one error that might realistically happen is a version mismatch between the loader and the plugin.
So we want to report that with a proper value instead of just going "sorry something went wrong" which is definitely a pain when it happens on the PC of an artist, who doesn't have any kind of debugger installed.
If we could just tell them "run an update yo", it'll save time
 
nwp
10:13 PM
@EtiennedeMartel I thought that is on the checklist anyways.
 
10:28 PM
@EtiennedeMartel Hmmm...well, if the plugin doesn't have the interface you're going to use, the obvious return would be E_NOINTERFACE. If the interface is present, but they try to use it in a way that's not supported, that would probably be E_INVALIDARG. For what you're describing, it probably makes the most sense as E_NOINTERFACE; any time you receive that, telling them to update is a pretty reasonable reaction.
 
@EtiennedeMartel I found the problem.
 
Famous last words.
 
10:49 PM
I just spent the whole day at work working around the fact that operator new doesn't sufficiently align for the datatype. Is there a reason why (as far as the standard goes) operator new doesn't align? It knows the type. Therefore it knows the alignment. I don't see any obvious technical barriers.
 
it delegates to ::operator new which does not receive the alignment as an argument.
the alignment is supposed to be handled by simply always aligning for the maximum possible required alignment for any data type, but that does not include extended alignments like SSE types, if memory serves.
 
@Mysticial Poor soul
 
@Borgleader I spent the morning pulling out my hair over how hard it is to write your own allocator.
 
@Puppy Sounds right to me. C (and C++) in general used to prohibit the basic notion of a type that had an alignment requirement that was larger than the type itself.
 
10:52 PM
Then in the afternoon, it was all TMP and implementing my own make_aligned_unique<>() bullshit.
 
@Mysticial Oh thats pretty old, instead there a simpler interface with C++11?
 
I seem to recall that SSE types still don't, but for some reason they are still not considered as part of the maximum alignment.
@Borgleader Yep, there is a minimal allocator interface with C++11.
 
@Mysticial I had this problem, and found working code on Google...
 
@Mysticial Not quite that hard any more. A more current guideline: howardhinnant.github.io/stack_alloc.h
 
IIRC STL has a video where he explains the new allocator requirements.
 
10:58 PM
@StackedCrooked That's pretty cool.
 
@JerryCoffin That looks just about as complicated as the one I found.
I actually went around a few places to see if there was something more recent that was simpler. They were all about as bad.
 
@Mysticial Oops--that's still a C++98 one.
34
A: Questions about Hinnant's stack allocator

Howard Hinnant I've been using Howard Hinnant's stack allocator and it works like a charm, but some details of the implementation are a little unclear to me. Glad it's been working for you. 1. Why are global operators new and delete used? The allocate() and deallocate() member functions use ::opera...

That has a simpler one.
 
Oooh... I didn't find that one.
 
that's what the doctor said when looking for your dick
 
Don't let Dr. Pepper touch you there, he's not a real doctor.
 
11:20 PM
Who wants to bet this OP is a former Java user?
-2
Q: How do I tell a program where to start reading a .txt file?

ntjessI want my program to be able to remember where it left off in a .txt file in order to proceed to the next input upon reiteration through a loop. For instance, a text file containing: Apples Bananas Oranges would be accessed through a function GetItem() that appends the next file input into a v...

 
I have a weird ownership scheme that kind of forces me to use raw pointers/new/delete.
send help mum C APIs suck
 
use a pointer wrapper class with a custom destructor?
 
a what
 
std::unique_ptr?
 
11:22 PM
I can't
basically the C API stores it
and then in a callback in the future
it tells me when I should delete it
 
So, I had something like this and I mirrored the internal structure with a std::map
 
Hey ppl i hve a little question
can i use realloc to alloc array?
 
Due to bugs in the vendor's API some of the pointers were being lost
 
if yes will it be like malloc or alloc
 
11:24 PM
calloc(
*
 
@DeBanana Yes. malloc.
 
@DeBanana Thats a terrible question because it shows a lack of a basic understanding of C++ and Google
 
I hope pointers aren't lost here
 
C*
 
@DeBanana this is Lounge<C++> not Lounge<C>
 
11:25 PM
also not C*
 
its kinda similar
 
maybe C#
 
@Mysticial Which had a link to this.
 
not really
 
C program can be executed as C++
 
11:26 PM
@DeBanana Yeah--in kinda the say way a desert and an ocean are almost the same.
 
yikes
 
let the star bait begin
 
anyway
 
C++ ppl are cruel
9
 
it feels dirty doing all this new/delete and weird ownership scheme
 
11:27 PM
and cold
 
Dealing with bare metal makes you have a cold heart.
 
@JerryCoffin ...and oh, look at the wonderful advice in the comments.
use fopen() then at the end of the looping fclose... see the exampleDIEGO CARRASCAL 44 mins ago
 
@Rapptz Its also dangerous, because pointers are typically not compatible between MSVC RTs. Some guys at the HDL group told me the correct solution is to return numbers similar to OGL contexts.
 
BTW got one more question
malloc reset values of struct?
to 0?
 
@Mikhail hm?
 
11:29 PM
You know what ill check the ref...
 
RTs being
 
@DeBanana Our work here is done.
 
Visual Studio Runtime
 
ah
not really seeing the relevance in this case
 
@Mikhail Unlike some older versions, which were so slow they had walk times.
 
11:30 PM
it's being stored as a void*
 
@JerryCoffin Visual Studio Funtime
 
@Mikhail Aka "uninstall time". :-)
 
@Rapptz So, if somebody gets clever and tries to delete a pointer returned from your API terrible things will happen
 
Ok so how can i initialize the values of an array of structs without to go through the whole array (considering using the realloc function )
 
oh the person using my API won't deal with pointers
this is all internal stuff
 
11:31 PM
@DeBanana Write a constructor for your struct (and use std::vector instead of malloc, realloc, etc.)
 
@Rapptz Sounds bad, typically I do a C-API at the face of my DLLs and C++ internally.
 
@Mikhail The way I solved that problem was to implement my own unique_ptr. On construction, it basically stores a function pointer to a local deleter. That way it can be passed around through APIs no problem.
 
no DLLs here
 
@JerryCoffin Ill still need to loop it tho no?
 
I'm not the author of the C API :|
(the C API in this case is actually cURL)
 
11:33 PM
@Mysticial Well, that doesn't quite solve name mangling, and doesn't prevent the user from doing something stupid.
 
@DeBanana Yes. Then you loop the other one, and cross this one under that one like this, and there, that's how you tie your shoes.
 
@Mikhail Then you flatten it.
You use a meta-object which is pure C.
 
Thx man couldn have done it without u!
 
Hide the API-crossing C function itself. And wrap it on both sides of the DLL.
 
:P
 
11:34 PM
That way you preserve the C++ semantecs on both sides.
It's messy though.
I spent a good month last year working this out.
The only thing it fails at is passing exceptions through the DLL boundary.
 
@JerryCoffin hehe
 
@Mysticial Or rather DLL boundaries, in general, fail at passing exceptions. In my case I used C style error codes...
 
@Mikhail It can be worked around. But it does require building a pretty hefty infrastructure on both sides of the DLL.
Make all your exceptions serializable.
Have a database. And build it on both sides of the DLL.
 
@Mysticial But I don't think Windows has this mechanism? You need to mirror both sides and match the exception codes? Or maybe I'm wrong about Windows...
 
@Mikhail I'm saying if you have full control over the API, there is a way to work-around even the exceptions. It's just fugly.
 
11:38 PM
@Mysticial The trick is to dump the user facing part as a C-API and have your users deal with that :-)
 
Basically, you catch the exception when you're about cross a DLL boundary. Serialize it and send it as a raw byte stream. Once you're across the DLL boundary, deseralize it. Hash table lookup the exception type, rebuild, and rethrow.
For user-made exceptions that the DLL doesn't know about, you don't rebuild it. You can't do anything with it anyway. So just wrap it and rethrow until it goes back to the user-side.
 
user406009
Seems like too much of a pain.
 
user406009
Probably better to just pass around error integers and strings.
 
coliru.stacked-crooked.com/a/5cf587f6886e0626 this is kind of what I'm doing
 
user406009
@Rapptz that's the correct ownership pattern for a once only callback.
 
11:48 PM
yeah the callback tells me when to delete
 
user406009
I hate APIs that do that, but that's how you deal with it.
 
@Mysticial By serialize did you return an exception code and then re-throw? Or is there some trick?
 
@Mikhail Java-style serialize. Make it a requirement that all exceptions inherit from it and implement a serialize() method as well as an exception-code key/deserialize-function-pointer value.
 
00:00 - 16:0016:00 - 00:00

« first day (2118 days earlier)      last day (2813 days later) »