« first day (3042 days earlier)      last day (2120 days later) » 
00:00 - 21:0021:00 - 23:00

12:00 AM
It's rolled over to actual voting now, but th post never got pinned it seems
@Flexo what brings you here?
12:20 AM
it's on my favourites list still
been wondering about compile time introspection proposals a whole lot lately too
ooh, risky stuff man
do me a favour would you, slap a pin on this please
the other room owners are being useless
2
 
3 hours later…
3:15 AM
It's weird, sometimes I get this happiness feeling even though there is nothing there. Future is dim, but who cares because I am happy. It's like the polar opposite to depression. Depression does not need a reason, neither does happiness.
Today I am reading some A.I. book. Instead a bunch of rather 'weird' ideas have filled my brain.
1) Why is that all other wildlife can poop and urinate everywhere in the neighbourhood, but humans can not. Are wildlife getting preferential treatments?
2) Can cloud carry viruses?
3) Can anyone who has accurately predicted future setup a cult, call it, say 'ProbabilitiesCult' and claim to have a brain similar to a receptor to the alien transmission?
4:17 AM
@TelKitty 1) yes. 2) yes. 3) Pretty much anybody can claim anything they want. Most of it's ridiculous, but that hasn't stopped them yet.
4:32 AM
hey guys i have an issue bugging me quite a lot lately...
(gdb) bt
#0 0x0000003d5ec9d4b6 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() ()
from /usr/lib64/libstdc++.so.6
#1 0x000000000041a636 in ~BiccAPMParam (this=0x7f1c983e7240, __in_chrg=<value optimized out>) at bicc.h:135
#2 0x0000000000420c29 in BICCEvent::~BICCEvent (this=0x7f1c983e6b70, __in_chrg=<value optimized out>) at bicc.h:232
#3 0x0000000000420c8a in std::default_delete<BICCEvent>::operator() (this=0x7f1ba13fbdd0, __ptr=0x7f1c983e6b70)
at /opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/bits/unique_ptr.h:67
wtf is that
this is the gdb stack trace...
GCC 4.8.2 <- ಠ_ಠ
it does not tell you a lot when you get all the stack from std lib...
Is there a question here or did you shit out a stack trace from a compiler that is old enough to fuck?
4:34 AM
yeah production still runs that in this portion of the world....:(
What is the question?
the question is i dont define the destructor in the class....and i used unique_ptr...
unique_ptr is in the std::queue...
#ifndef CUSTOM_QUEUE_H
#define CUSTOM_QUEUE_H

#include <logger.h>
#include <queue>
#include <pthread.h>

template <typename T>
class ThreadSafeQueue
{

private:
std::queue<T> _queue;
pthread_mutex_t queueMutex;
pthread_cond_t emptyCondVar;

public:
ThreadSafeQueue();

bool volatile Stopped;

void Enqueue(T data);
T Dequeue();
void StopQueue();
void DestroyQueue();
//void Empty();
};

template <typename T>
ThreadSafeQueue<T>::ThreadSafeQueue()
{
pthread_mutex_init(&queueMutex, NULL);
pthread_cond_init(&emptyCondVar, NULL);
thread library is pthread...so i wrapped std::queue in that...
while (biccEvent = std::move(deliverQ->Dequeue()))
First off your code is not quite paradigmatic because you're not using std::thread, if you're too poor to afford a newer copy of GCC consider using boost::thread, which has the same interface as std::thread
Also still no question.
pthread with that cpp std lib queue -- is this a bad practice?
no hold on...
pthreads in C++ is bad practice because it doesn't have RAII style wrappers, aka no std::unique_lock automatically releasing the mutex, also pthreads operates with handles which require ownership management. pthreads is not C++, its C
4:41 AM
the question is when the unique_ptr is moved to the new place then the already assigned is destroyed and hence the destructor....but why it is generation this kind of issues?
its very random....
okay i haven't got that hint from any place when i implemented that std::queue wrapper...
thanks @Mikhail for the suggestion....
T elem = std::move(_queue.front()); will set the old pointer object inside queue to null, this is required/designed/explicitly written behavior for unique_ptr
yess that is true....and that is cpp territory i guess...
then i need to do _queue.pop()...
didn't you?
yess i did...
but when did i step on the wrong foot with pthread?
I don't know what you mean, but I would write it the way god intended and switch to std::thread
My cargo cult believes that writing paradigmatic code keeps bugs out
4:53 AM
:D you are good with words....i must say...:D:D
i get it....i need to go c++14 for the mutex then....
i used read/write lock for the vectors....
35
Q: How would you implement your own reader/writer lock in C++11?

jackI have a set of data structures I need to protect with a readers/writer lock. I am aware of boost::shared_lock, but I would like to have a custom implementation using std::mutex, std::condition_variable and/or std::atomic so that I can better understand how it works (and tweak it later). Each d...

or boost...
thanks man....i really appreciate the effort....@Mikhail
 
3 hours later…
user7659542
8:14 AM
@Mikhail subscribed.
8:39 AM
fug, I have a race condition in a single threaded code
user7659542
@Mikhail multiprocess?
@thecoshman sorry, only just noticed that
Basically, there is some kind of race condition in Qt's GUI. I have a setData command that moves around some widgets, somwhere else when I query those widgets it causes a segfault. It has to be the same thread else, Qt would croak, maybe.
9:13 AM
What has happened to Robot? Is he so happily married that he is neglecting his projects?
9:34 AM
@Flexo huh, well, someone pinned it. Thanks anyway
10:23 AM
> I would love to contribute to The Qt Project in the upcoming Google Summer of Code 2019.
Found in the Boost mailing list
There's a paper on arXiv about « Ultimate Heapsort » and from its description I fail to see how it's different from a bais heapsort
Heapsort, more like cheapsort
 
2 hours later…
user7659542
12:39 PM
Considering a very short piece of code, when do you guys usually go for a macro instead of a function?
user7659542
except for speed reasons, because the preprocessor replaces your macro, I don't see why one woudl go for a macro instead of a function
I never use macros unless the language doesn't provide a replacement
Basically whenever it can be a function I make it so
1:17 PM
Mmmmh, looks like I forgot to mtime_cache my header files, which might explain why I always get full rebuilds of my test suite
It would really be great if I managed to make that work
nwp
nwp
I found a deadlock, tried to debug it, crashed gdb repeatedly, tried to reproduce on Linux, failed, and can now no longer reproduce on Windows either.
Go me fixing bugs making bugs disappear.
Don't write deadlocks
nwp
nwp
On the plus side I did manage to actually fix some bugs which made a lot of other bugs disappear. That's good, right?
I mean, yes, probably
@traducerad NOPE
user7659542
1:25 PM
@Mgetz Care to elaborate?
@traducerad macros are an unholy pain to debug, rather I'd use an inline function if I must, but would still be suspicious of that as a linker can easily optimize that if I do things right.
There is no logical reason to EVER use macros for functionality in C++ other than #ifdef
user7659542
@Mgetz I have the same opinion. So I am wondering why somebody would do that. The only good thing I have seen with macros so far is called an "X-macro"
nwp
nwp
Besides lifting.
@traducerad you might see some for string constants, but honestly even then I'd be suspicious
@Mgetz code generation sometimes
user7659542
1:28 PM
@Mgetz I am asking this question just after having read some C code
@Morwenn in modern C++ you'd have to convince me... and I'd be really skeptical
@traducerad oh I'm sorry
user7659542
@Mgetz my bad, I am more a C guy
user7659542
still working on my cpp skills though
nwp
nwp
@traducerad You often have no alternative in C.
@traducerad if you're using C you're screwed because you don't have templates
good luck with that
nwp
nwp
1:29 PM
Can't even make a constant in C without macros.
@Mgetz I mean, just look at any library trying to provide reflection in standard C++ and which isn't magic_get
@Morwenn I didn't say I wouldn't consider valid uses, I just said I'd be skeptical
Copying tons of boilerplate is more error-prone than macros in the end
also Catch2 & other test frameworks
Nah, macros still allow for night black magic from time to time
But in everyday programs you hardly ever need to define any yourself
@Morwenn This would be more my stance, and one supported by what I'm seeing from the committee
user7659542
#include <stdio.h>

#define SET_VAR(_array_, _pos_) \
    _array_[_pos_]=true; \

int main(void)
{
    //...
    if (foo == true)
    {
        SET_VAR(my_array_of_booleans, 55);
    }

    return 0;
}
user7659542
1:33 PM
@Mgetz this is a summary of the code I read. I was wondering why would you absolutely use a macro there and not a function or even an inline function
thanks, I hadn't cried enough in two weeks
@traducerad I would absolutely reject this in code review as both a violation of the standard for __ defined identifiers and because it obfuscates the actual functionality
@Morwenn Liar. I am sure you cry yourself to sleep every day! :D
nwp
nwp
@traducerad For what? Both macro and function are only obfuscation with no benefit.
Nah, only when I'm too depressed
1:34 PM
@traducerad Also, if (foo == true)?
I did cry at the restaurant yesterday because I was talking about people I know who are actually too wholesome and it brought me to tears
user7659542
@wilx ?
nwp
nwp
You should make that explicit. if ((foo == true) == true). Better be safe.
@nwp needs more factory
user7659542
@Mgetz Any sources about "standard for the __ defined identifiers"?
user7659542
1:37 PM
Why do you think it obfuscates the actual functionality? Do you mean you would just have written the code of that macro straight there?
nwp
nwp
truthGeneratorFactorySingletonBean::generateTruth().
> ) All identifiers that begin with an underscore followed by a capital letter or by another underscore (these reserved identifiers allow the library to use numerous behind-the-scenes non-external macros and functions)
That's for C but it's the same for C++
nwp
nwp
@traducerad yes
@traducerad It is considered good practice to not compare boolean variables against true or false but just use foo and !foo in conditionals.
nwp
nwp
1:39 PM
You mean not foo :P
Today I learned travis_retry exists. Neat.
user7659542
@wilx Why?
in C#, Sep 20 '16 at 18:08, by milleniumbug
@Donovan because you say "if a loop word in a current_line+1 is not visible do this thing" and not "if a loop word in a current_line+1 being visible is false do this thing"
@traducerad Because it is shorter. Because it is more similar how boolean logic is written in maths.
user7659542
@wilx that sounds very subjective. Yes, it is shorter. But it is not because it is shorter that it is better practice
@milleniumbug How do you find a quote from 2016 about this?
1:44 PM
it's my own quote, so I remembered
Also because some classes have explicit operator bool which works for specific places like if or not, but don't work with comparison
"if not is_selected, do this" vs "if is_selected is equal to false, do this"
@traducerad As others are showing, there are other reasons, too.
If your class Sugar has an explicit operator bool, which is the proper way to make classes that can be tested in boolean contexts, if (sugar) will work, if (not sugar) will work, but if (sugar == true) won't work
user7659542
btw, any of you familiar with the different middleware libs? Corba, DDS, etc
user7659542
1:47 PM
Which one is your favorite?
@traducerad Corba is dead. What's DDS?
nope
nwp
nwp
> To enable debug for your public repositories, please email us at [email protected] and let us know which repositories you want activated.
user7659542
recently tried protobuf, but I wasn't a very big fan of it
nwp
nwp
1:49 PM
So travis isn't just bad and not debuggable. It's debuggable just fine. They just don't enable the feature.
@wilx Doctor Of Dental Surgery?
user7659542
@Mgetz I actually meant a link or something to a solid source I could read
user7659542
@Mgetz but that's about c++
user7659542
:'C
1:52 PM
@traducerad no that's the C documentation on that site
the second link is C++
user7659542
@Mgetz ok!
user7659542
@wilx Ever used dbus?
user7659542
2:22 PM
@Mgetz funny thing is, the company where this code was written doesn't do code reviews
user7659542
so they would have totally bypassed you
@traducerad In which case I would have found a new job
if the company doesn't do code review then they are failing at even the most basic of best practices
user7659542
@Mgetz totally agree!
@traducerad Protobuf only handles serialization. A direct Corba equivalent would be gRPC.
user7659542
But I think teaching how to do code reviews to junior developers is far from being easy. What are supposed to tell them? "Hey, just look at that code and make sure it respects our internal coding standard", but there is so much more you should actually look at.
user7659542
2:28 PM
@Mgetz
user7659542
That place I am referring to almost only has juniors, the seniors all left
@traducerad explain why, what is the anti-pattern and why does it matter. Just enforcing standards is cargo cult.
You need to build consensus on why it's an anti-pattern and what the better approach is
user7659542
@Mgetz like why not using fixed width variables is an anti-pattern? :p
nwp
nwp
That is definitely worth debating.
@traducerad if I see for(int32_t i = 0; i < 10; ++i) that's an antipattern on almost all hardware
there is ZERO reason not to use int there
to be fair in most of those cases I would say use a ranged for anyway
in which case I don't care
user7659542
2:32 PM
@Mgetz a reason could be that you want to stay consequent with the rest of the whole codebase, don't start mixing fixed and variable width
@traducerad so we're lemmings now?
continuing potentially bad practice because someone else did it?
nwp
nwp
I don't think I have ever needed fixed width integers.
Serialization and ABI
that's the two cases I've needed em
user7659542
the debate has already been done
2:33 PM
but otherwise they are almost always not worth it IMO
nwp
nwp
I very rarely send data to other devices and when I do I use gRPC or equivalent which uses fixed-width integers already.
user7659542
let s not go down that rabbit hole again : )
@nwp puppy has apparently never had to deal with non-x86 processors and doesn't believe RISC exists
user7659542
@nwp I have to do that every day
nwp
nwp
In theory I have to do that every day too because embedded stuff talking to PCs via comport/bluetooth/USB. In practice I wrote an RPC thing with fixed width integers and the rest of the code uses int and it has never caused a problem.
Although that might just be because the embedded chips are actually 32 bit processors where ints are the same size anyways.
user7659542
2:40 PM
@Mgetz I feel like a pattern which should be enforced everywhere and I haven't seen that much is to always make every read-only value const
@nwp my argument was that in the 98% of cases where you need to use a value you know what range it's in... and can use a standard type that has guaranteed width for that without using fixed width.
so you don't need to over-optimize on fixed width
@traducerad I'd prefer constexpr when possible, and const when not
nwp
nwp
@traducerad -Wsuggest-attribute=const. Don't waste development time on such nonsense.
user7659542
@nwp hmm, interesting
I love it when Git does a dumb and I fix issues by stashing/unstashing modifications
user7659542
Git for the win!
user7659542
2:44 PM
Why is svn even still a thing nowadays?
@nwp lol
because people who haven't learnt to love branches find SVN easier to use
nwp
nwp
What does that say about people using single-branch git repositories?
user7659542
@Morwenn we work in a sector where if you don't follow and learn to work with new stuff you'll be left behind very quickly
you can still be a succefull and loved COBOL programmer in 2019 x)
2:47 PM
@nwp There is actually a tool the chrome folks use to scan the codebase for runtime initialized const variables to ensure they make them compile time if possible
Also people don't want to learn new technogolies when they feel that the ones they have adequately solves their issues
well it scans the binaries actually
@Morwenn and extremely highly paid
user7659542
@Mgetz what is "extremely highly"? according to ziprecruiter.com the average salary is 61k
user7659542
the highest salary for US developers I know about is 150k/yr
@traducerad lol, some banks are advertising 150-200 for anyone competent in COBOL
most COBOL folks I've met prefer to consult though
they an easily get 800/hr
user7659542
2:55 PM
@Mgetz is this a joke? In Western-Europe most senior consultants get 650/day
user7659542
but those people write C/C++
Cobol gets 800/hr. Is the syntax hard to master
user7659542
@Mgetz you just get your lame ass down, poor yourself some coffee, turn on your computer and boom 800usd
@traducerad no, it's not a joke. They have to know about 6-10 different dialects, and more subdialects.
it's not easy to get to that point
they know more about the interpreters/compilers than some of the people that maintain them
user7659542
@Mgetz any chance a C-programmer can get to such a high pay?
2:57 PM
Most know the usual dialects of IBM COBOL and it's subdialects
@traducerad HAHAHA no
people are still learning C
it has many of the dialects issue of COBOL though
user7659542
I ve been considering to go into VHDL, because I like it and that pays very well too (not like COBOL)
I hope you speak Mandarin or Cantonese
user7659542
@Mgetz why so?
because that's what you need to know to talk to manufacturers
google translate should be good enough
2:59 PM
or if you're working with intel... three languages in Malaysia
user7659542
@Mgetz how does this relate to VHDL? many companies in the space industry and telecom use vhdl
@traducerad Telecom yes, automotive yes. Space industry... lol
they use parts that are older than some people's kids
user7659542
@Mgetz they deffinitely do!
user7659542
@Mgetz they do in the aviation industry. but not necessarily in the space industry
3:02 PM
@traducerad I have friends at Sierra Nevada, Lockheed, and Ratheon.. all of them use stock off the shelf rad hardend parts
they absolutely would NEVER use an FPGA for flight hardware
@traducerad aviation maybe, but only under FL50
user7659542
@Mgetz you sure? Not sure they are allowed to tell you what they use : p
anything over that you need to start using rad hardened parts again
@traducerad hardware is mostly unclass
at least as far as that goes
user7659542
This being said, I am currently diving deeper into driver development, RTOS and kernels. I think once I have done that for 1-2 years, it would be nice to switch to FPGA's for 3 years
user7659542
and then start consulting
user7659542
but I won't have done any cpp
3:06 PM
The RAD750 is a radiation-hardened single board computer manufactured by BAE Systems Electronics, Intelligence & Support. The successor of the RAD6000, the RAD750 is for use in high radiation environments experienced on board satellites and spacecraft. The RAD750 was released in 2001, with the first units launched into space in 2005.The CPU has 10.4 million transistors, an order of magnitude more than the RAD6000 (which had 1.1 million). It is manufactured using either 250 or 150 nm photolithography and has a die area of 130 mm2. It has a core clock of 110 to 200 MHz and can process at 266 MIPS...
That's what quite a few of them are using
@traducerad you can actually write more efficient kernels in C++ than C
but Linus
seriously the bias against C++ in embedded is kinda sad
user7659542
@Mgetz would be nice if they had some opensource IP-cores. I'd throw them on an fpga, work with them during my free time and make sure to become an expert at them
@traducerad it's powerPC
that's why most places use it, development hardware doesn't need to be Rad hardened
user7659542
@Mgetz haha which is mostly used in the aviation industry afaik : )
Literally the whole point of that processor is to be a drop in replacement for a non-radhardened part
user7659542
@Mgetz A couple of years ago when I applied for my first job, they required me to know C and C++. So I asked them -out of curiosity- why they didn't use cpp on their embedded devices. The answer was mostly that the issue with cpp is that there is a lot of stuff going on behind the scenes. This is something you don't want when working on a device with limited resources
nwp
nwp
3:13 PM
Arguably they are just blind.
user7659542
As said I am no cpp expert, but for example: it seems like when doing a dynamic cast you actually somehow behind the scenes dereference the pointer you are passing. when working with vectors I believe you are doing a dynamic allocation when adding a value to the vector. Etc...
user7659542
just to show there is more going on than you might see at first sight
@traducerad yeah... go watch some of the CPPCON videos, that's garbage
if you're using v-tables in embedded that's your problem
but you don't have to use that
or exceptions
and things like templates and constexpr are too useful to ignore
user7659542
There is also a reason flight software for aircraft is not written in C++
@traducerad because it's in FORTRAN?
and has been for the last 20ish years
or longer
user7659542
3:15 PM
@Mgetz or C
user7659542
* airbus waves at you *
@traducerad there isn't actually other than momentum. JPL switched all new projects to C++
@traducerad Jeppesen waves back
as does Boeing
but yeah Spirit and Opportunity, and Curiosity are all running C++
for what it's worth most new DOD internal projects are C++
user7659542
Doesn't spaceX use C?
@traducerad no idea
I wouldn't be surprised if they got caught in that trap
but honestly there isn't a good reason to use C anymore other than you prefer it. Even in embedded
user7659542
@Mgetz they got the very finest engineers over there. I am sure they know what they are doing
3:22 PM
@traducerad actually they don't, Musk has driven most of them out of the company. The problem is he expects people to work like he does... and he is a workaholic
most people don't work 60+ hour weeks standard
user7659542
@Mgetz How else are you going to become the best at what you do?
I know more people that have turned down jobs from SpaceX than work there
@traducerad with good planning and rest, overworking yourself actually degrades your skills
@Mgetz what reason could you have for not wanting to work at SpaceX
user7659542
@Rick 60h workweek
user7659542
"don't bother coming on Sunday if you weren't there on Saturday"
user7659542
3:25 PM
@Mgetz any books you could suggest me on that topic? As I am for a C background?
user7659542
I was a bit disappointed by stroutrup's book
user7659542
(or however you write his name)
user7659542
@Mgetz watched this video a couple days ago! :)
user7659542
3:29 PM
stahp it, you are going to make me feel like I wasted the past years of my life by writing C
user7659542
@Mgetz
@traducerad because you did?
sorry I had to
user7659542
@Mgetz Linux, C, and maths
user7659542
and some Qt for gui's
user7659542
but nothing fancy
3:31 PM
@traducerad Linux: Linus is an opionated idiot, but it's his kernel. Maths: there are actually some better languages than C or C++ for math... most notably FORTRAN
user7659542
@Mgetz or Matlab, which I didn't mention
@traducerad still better than both C and C++
at least at math things
user7659542
issue is you need to be able to find a place where: 1) they write proper C++ 2) a place -in mycase- where they use C++ not only for desktop applications and stuff but real embedded things
@traducerad define 'proper' c++
they are using constexpr templates etc
user7659542
@Mgetz yes, this for example.
3:33 PM
to me that's 'proper' c++
you don't need to use exceptions
that's optional
it's nice when you can
but not appropriate for all environments
that said that list of environments is growing
4:13 PM
@traducerad a bit of advice you shouldn't waste time learning many different languages, just learn one and focus on data structures. Once you have that down it won't matter what language you use.
in all honesty, they all seem like different dressing for the same salad
@Rick I have yet to code a shader in Javascript
well you can
@Rick technically no, webgl just loads them in as GLSL strings
4:32 PM
so is this book wrong thebookofshaders.com/appendix/04
@Rick no that book is talking emulation in JS
real shaders are a distinct DSL
ex: foo.xyzw = bar.zxwy
that actually means something very specific in a float4
and in most shaders is a single op
nwp
nwp
@traducerad That's why you hire people with experience who also know that when you are casting you are most likely doing it wrong.
nwp
nwp
@Mgetz That is a terrible video that I would hide in shame.
user7659542
@nwp I don't know that much about cpp, some guy with 3 years of experience came up to me asking whether I understood why he was getting a segfault. Based on my knowledge of C I knew that chances were very high he at some point or another he was probably dereferencing a NULL ptr. Turns out the exact line where he segfaulted was where he did the dynamic cast, only possibility is that this thing does some dereferencing behind the scenes
user7659542
4:41 PM
turns out I was right
nwp
nwp
I don't know what to tell you. That guy with 3 years experience was simply not qualified.
@traducerad depends on what you're dynamic_casting
nwp
nwp
You are expected to know what dynamic_cast does and have an idea how that is implemented and not to use it.
user7659542
@Mgetz it was a vector of pointers or smth like that IIRC
dynamic_cast is for a very very specific use case
@traducerad of a specific parent type?
or....?
because dynamic_cast is not safe for use with void*
user7659542
4:44 PM
@nwp I asked him whether it was possible for him to modify his dynamic cast in a static cast. That way you have "a check" done at compile time instead of at runtime. That s more or less where I left it. He told me the dude before him already did a dynamic cast, which is why he continues
with void* it's always hold onto your butt and pray
user7659542
@Mgetz sorry don't remember I know he was doing it in a derived class, but that's all I can remember
@traducerad yeah.... dynamic_cast pretty much ONLY exists to do a type safe downcast
beyond that it's not safe at all
so if he was getting a segfault he was using it wrong
user7659542
@Mgetz nobody is there to tell him. And I am not a cpp expert, I only suggested him to consider changing his dynamic cast to a static cast
user7659542
if possible
user7659542
@Mgetz does that mean that you can cast a base class to a derived class but not the other way around?
when in doubt make sure it's the right thing
@traducerad correct, going to a base class type checking isn't actually even needed per se IIRC
it's implicit
user7659542
alright
user7659542
brb in an hour or two
2317
A: When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used?

copprostatic_cast is the first cast you should attempt to use. It does things like implicit conversions between types (such as int to float, or pointer to void*), and it can also call explicit conversion functions (or implicit ones). In many cases, explicitly stating static_cast isn't necessary, but it...

user7659542
4:49 PM
@Mgetz haha was just googling this : )
basically dynamic_cast should be considered to be the standard version of COM's QueryInterface
either it succeeds or fails, but it has a very defined contract
nwp
nwp
Or you access a non-existant object which causes UB :D
5:42 PM
6:38 PM
Power out for 9+ hours yesterday, so far we had 3 (electricity + water) outage in as many years, Australia has relapsed into an underdeveloped country. Talking about unwanted backward compatibility.
Had to use candles and camp lamps. Good thing is that I do have quite a few rechargeable camp lamps.
 
2 hours later…
user7659542
8:12 PM
TIL in C some people define structures like this:
user7659542
#define MY_STRUCTURE(structB) \
{"some text", &(structB->foo), NULL} \
{"abcdefght", &(structB->bar), NULL} \
user7659542
void myfunction(structB)
{
    //...
    MY_STRUCTURE(structB);
    //...
}
user7659542
Why not just use a structure? Why do you need to go via a macro?
user7659542
correction:
user7659542
void myfunction(structB)
{
    //...
    smth_t myArrOfStructs [] =
    {
        MY_STRUCTURE(structB);
    };
    //...
}
user7659542
8:22 PM
you are just winning some space in your file, that's it
8:36 PM
X macros, more usefull when you have more times you need to do something per element in a list
user7659542
@ratchetfreak I am not sure I understood what you meant. But to me it looks like X macros are only good for winning space in your file
it prevents typos when you first want to list them multiple times
8:51 PM
@traducerad This was quite common before template code generation didn't suck
user7659542
@Mgetz I find this an interesting approach because the people claiming macros are unsafe can be proven wrong with this example
user7659542
so setting up coding rules in your company telling macros are forbidden may be "harmfull"
user7659542
an X macro is usefull and not type unsafe
user7659542
as far as I can see
user7659542
This being said when you are constructing an API, you should define such X macros inside your source file and not inside your header file imo
user7659542
8:56 PM
the code I looked at defined them all in its header file
00:00 - 21:0021:00 - 23:00

« first day (3042 days earlier)      last day (2120 days later) »