Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
In case you didn't want to go to the trouble of running code, the problem is that the C++ preprocessor does a simple text replacement, so something like

6 * ADD(3, 5)

becomes 6 * 3 + 5, which is 23, not 48 like you would think to look at it.

The usual way you would correct this is to add some brackets in the macro definition:

#define ADD(x, y) (x + y)

Adbot
ADBOT LOVES YOU

qntm
Jun 17, 2009
Oh, I should have known that.

Volguus
Mar 3, 2009
An even "more correct" way to write that macro would be

#define ADD(x,y) ((x)+(y))

since, again, you can be bit in the rear end for certain values of x or y. While macros are not evil per se, they do open a can of worms if left unchecked, a relatively hard to debug can of worms.

feedmegin
Jul 30, 2008

hobbesmaster posted:

Unions are also classes if we're talking about C++ trivia.

I have no idea why.

At a language implementation level they're quite similar; it's just that the offset from the memory address of the variable for all their members is 0 and the size is the largest size of any given member rather than the sum of the sizes of the members (modulo alignment adjustments).

MrMoo
Sep 14, 2000

Hammerite posted:

If you want to determine whether the candidate knows the difference between a class and a struct, why not ask them "what's the difference between a class and a struct?"

I was asked but then followed up with this more trivia type questions, it was really a bit tenuous. They still want to interview me which suggests there are not a lot of C++ people really looking for jobs.

ToxicSlurpee
Nov 5, 2003

-=SEND HELP=-


Pillbug

MrMoo posted:

I was asked but then followed up with this more trivia type questions, it was really a bit tenuous. They still want to interview me which suggests there are not a lot of C++ people really looking for jobs.

There just aren't enough programmers in existence in general.

hobbesmaster
Jan 28, 2008

MrMoo posted:

I was asked but then followed up with this more trivia type questions, it was really a bit tenuous. They still want to interview me which suggests there are not a lot of C++ people really looking for jobs.

There also aren't all that many C++ jobs out there.

Tomahawk
Aug 13, 2003

HE KNOWS
And this thread is making me glad that I'm not a C++ programmer

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Tomahawk posted:

And this thread is making me glad that I'm not a C++ programmer

lol if you think Java is better than C++.
I wish Java had half the niceties of C++, also why am I writing Java I did not sign up for this.

fritz
Jul 26, 2003

leper khan posted:

lol if you think Java is better than C++.
I wish Java had half the niceties of C++, also why am I writing Java I did not sign up for this.

I've been trying to learn myself a scala and have been repeatedly pleasantly surprised at how much useful stuff's floating around out there in the jvm ecosystem, and in particular how nice it is to have a maven for managing dependencies instead of the c++'s world "good luck" policy.

ExcessBLarg!
Sep 1, 2001

leper khan posted:

lol if you think Java is better than C++.
But is your average C++ codebase "better" than your average Java codebase? How much C++ do you encounter in the wild that's modern C++11?

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

fritz posted:

I've been trying to learn myself a scala and have been repeatedly pleasantly surprised at how much useful stuff's floating around out there in the jvm ecosystem, and in particular how nice it is to have a maven for managing dependencies instead of the c++'s world "good luck" policy.
Can't argue that there isn't a lot of existing Java code. :v:

ExcessBLarg! posted:

But is your average C++ codebase "better" than your average Java codebase? How much C++ do you encounter in the wild that's modern C++11?
Among projects started in the past five years a fair amount..? Both languages have some issues with legacy.
I feel like C++ allows for a wider range on the "better" spectrum, ranging from horrifying to pleasant. Java seems to condense the range around annoying. I'd rather work with tools that can be nice, rather than tools that prevent me from losing limbs but remain generally unpleasant.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost

ExcessBLarg! posted:

But is your average C++ codebase "better" than your average Java codebase? How much C++ do you encounter in the wild that's modern C++11?
This is not a very fair question in many respects because the Java community of programmers is almost by market design more of a garbage fire than the C++ community (funny, this was inverted in 1997 given Java was the New Hotness). For every person writing crazy awesome stuff that happens to use Java just out of Big Company reasons you're going to have 100+ that are writing enterprise make-work gulag programs (I'm struggling with a programmer pun on "Arbeit macht frei").

fritz posted:

I've been trying to learn myself a scala and have been repeatedly pleasantly surprised at how much useful stuff's floating around out there in the jvm ecosystem, and in particular how nice it is to have a maven for managing dependencies instead of the c++'s world "good luck" policy.
Meanwhile, after spending years with the JVM I'm interested in Go and Rust primarily for their improved toolchains over C++. I'm also more interested in statically compiled binaries to the point of using other languages because so much work gets involved in effectively managing the rat nest of dependencies when you deploy at scale that I just don't care anymore and all I want is to drop a single, fat binary and just keep restarting it if it crashes. I vividly remember the problems I had just getting stuff to compile and link with shared libraries and so forth circa 2001 gcc 2, but now you can waste a lot of space on computers without being crucified in either code review or production.

fritz
Jul 26, 2003

necrobobsledder posted:

I vividly remember the problems I had just getting stuff to compile and link with shared libraries and so forth circa 2001 gcc 2

It hasn't gone away, we have to compile for a bunch of platforms (including android and windows) and it can be a real pain sometimes.

TopherCStone
Feb 27, 2013

I am very important and deserve your attention

necrobobsledder posted:

(I'm struggling with a programmer pun on "Arbeit macht frei").

Arbeit makefile is as close as I can get

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

TopherCStone posted:

Arbeit makefile is as close as I can get

free free macht Arbeit?

Adbot
ADBOT LOVES YOU

toiletbrush
May 17, 2010
I've been really lucky, every interview I've done from either side has been pretty good. The only exception was for my first job moving from low-level C stuff to web dev about ten years ago. All their questions were stuff I'd learned by googling 'asp.net interview questions' the night before, and then their lead asked how I'd add a repeater control to a page and I just said 'um...I'd type 'repeater' into the aspx file?' wondering if it was a trick question or maybe they'd ask me to expand on the page life-cycle or something, but nope, that was it, job done. When the recruiter got back to me he said they though I sounded like someone who could really 'go places' in the company and offered me a senior role :confused:

  • Locked thread