rbmj/612-code — comment on commit 03988c8c635ddaa4898298711319b30ff19dba42
File: joysmooth.cpp line 6
By anidev:

I think I sort of see... Thanks.

Sent from my Android device.

-----Original Message-----
From: "Robert Blair Mason Jr."
To: Anirudh B
Sent: Fri, 27 Jan 2012 10:24 AM
Subject: Re: [612-code] Made joysmooth more generic, minor changes to main/update. (03988c8)

Yes we do. Those will work, but they are technically not correct. With integral types, and only integral types, you are allowed to declare and define the constant in a header file. However, you still need to also declare it in a source file. Why? Because the compiler needs to know what translation unit the constant is defined in. If you called &joysmooth::HOLDBACK (legal, though I don't know why you would do it), the linker would not know where the space was allocated (in what translation unit) for joysmooth::HOLDBACK, so it would give a linker error. By providing this definition we allocate the physical memory to hold the constants if they are needed. Modern compilers will also optimize this memory out if it is unneeded with link time optimization (llvm is great at this).

---
Reply to this email directly or view it on GitHub:
https://github.com/rbmj/612-code/commit/03988c8c635ddaa4898298711319b30ff19dba42#commitcomment-908448