Click here to Skip to main content
15,441,280 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: moving graphics in a win32 c++ window Pin
Richard MacCutchan10-Aug-22 2:01
mveRichard MacCutchan10-Aug-22 2:01 
QuestionFileMapping book exmple goes in loop Pin
coco2438-Aug-22 8:48
Membercoco2438-Aug-22 8:48 
AnswerRe: FileMapping book exmple goes in loop Pin
Mircea Neacsu8-Aug-22 10:35
mvaMircea Neacsu8-Aug-22 10:35 
GeneralRe: FileMapping book exmple goes in loop Pin
coco2438-Aug-22 11:45
Membercoco2438-Aug-22 11:45 
GeneralRe: FileMapping book exmple goes in loop Pin
Mircea Neacsu8-Aug-22 11:47
mvaMircea Neacsu8-Aug-22 11:47 
Questiondefining a function with #define Pin
coco24330-Jul-22 9:03
Membercoco24330-Jul-22 9:03 
AnswerRe: defining a function with #define Pin
Mircea Neacsu30-Jul-22 9:54
mvaMircea Neacsu30-Jul-22 9:54 
GeneralRe: defining a function with #define Pin
trønderen30-Jul-22 12:46
Membertrønderen30-Jul-22 12:46 
Also worth noting: A macro does not define its own scope, the way a function does. It could refer to other symbols, say,
C++
#define PLUSX(i) (i + x)
Which x is added? That depends on where PLUSX is used. In one place it could be a different x than in another place. In a third place, there may be no x defined at all, and you get a compilation error, even if the two first uses of PLUSX went without any error.

A define is a pure textual replacement. If you in your code editor replace 'PLUSX(i)' with '(i + x)' (and change the 'i' in the replacement text to whatever was the name of your actual argument), you are doing by hand the work of the C preprocessor. Or in your case, if in your editor you replace
C++
int  nIconBytes = (EVENBYTE(nWidth)/8)*nHeight;
with
C++
int  nIconBytes = (((nWidth+7)/8*8)/8)*nHeight;
then you get the exact same result as with the #define.

Note: I am certainly not suggesting that referring to non-argument variables from macros is a good idea (usually is is not), but understanding how macros differ from functions includes understanding how such references would work.

Personal opinion: #define is among the most mis-used features of the C language. Except for giving symbolic names to simple constants, you should try to avoid it as far as possible.
GeneralRe: defining a function with #define Pin
Greg Utas30-Jul-22 13:58
mveGreg Utas30-Jul-22 13:58 
AnswerRe: defining a function with #define Pin
Randor 30-Jul-22 9:55
professional Randor 30-Jul-22 9:55 
GeneralRe: defining a function with #define Pin
coco2433-Aug-22 9:01
Membercoco2433-Aug-22 9:01 
QuestionHow to read an xlsx file using CDatabase Pin
Sampath57927-Jul-22 19:54
MemberSampath57927-Jul-22 19:54 
AnswerRe: How to read an xlsx file using CDatabase Pin
Victor Nijegorodov27-Jul-22 20:07
MemberVictor Nijegorodov27-Jul-22 20:07 
GeneralRe: How to read an xlsx file using CDatabase Pin
Sampath57931-Jul-22 23:27
MemberSampath57931-Jul-22 23:27 
GeneralRe: How to read an xlsx file using CDatabase Pin
Richard MacCutchan31-Jul-22 23:38
mveRichard MacCutchan31-Jul-22 23:38 
GeneralRe: How to read an xlsx file using CDatabase Pin
Dave Kreskowiak31-Jul-22 17:30
mveDave Kreskowiak31-Jul-22 17:30 
GeneralRe: How to read an xlsx file using CDatabase Pin
Sampath57931-Jul-22 23:40
MemberSampath57931-Jul-22 23:40 
GeneralRe: How to read an xlsx file using CDatabase Pin
Sampath5791-Aug-22 23:21
MemberSampath5791-Aug-22 23:21 
QuestionHow to use UTF8 characters in C++ Pin
JohnCodding27-Jul-22 3:00
MemberJohnCodding27-Jul-22 3:00 
AnswerRe: How to use UTF8 characters in C++ Pin
Mircea Neacsu27-Jul-22 3:54
mvaMircea Neacsu27-Jul-22 3:54 
GeneralRe: How to use UTF8 characters in C++ Pin
JohnCodding27-Jul-22 19:40
MemberJohnCodding27-Jul-22 19:40 
AnswerRe: How to use UTF8 characters in C++ Pin
Richard MacCutchan27-Jul-22 4:40
mveRichard MacCutchan27-Jul-22 4:40 
QuestionI Moved this question to the proper forum "Managed C++/CLI" - Sorry for posting in the wrong place :¬) Pin
madusmacus27-Jul-22 2:33
Membermadusmacus27-Jul-22 2:33 
AnswerRe: I hope there is a Managed C++/CLR person left to help me with Parallel::For Pin
Victor Nijegorodov27-Jul-22 4:02
MemberVictor Nijegorodov27-Jul-22 4:02 
GeneralRe: I hope there is a Managed C++/CLR person left to help me with Parallel::For Pin
madusmacus27-Jul-22 4:24
Membermadusmacus27-Jul-22 4:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.