C ++ skills

zhaozj2021-02-16  47

// Original Do / While Macro

// Original Do / While Macro

#define my_assert_one (x) do {/

IF (! (x)) {/

_ASM INT 3 /

} /

} While (0)

// new macro this removes the loop

// New Hong moved to loop

#define my_assert_one (x) {/

IF (! (x)) {/

_ASM INT 3 /

} /

}

Code List 4 Avoid a compiler error

(a). / * this code will cause a compile error * /

/ * This section will produce a compiler error * /

Void main (void)

{

INT i = 10;

Printf ("i:% d / n", i);

INT j = 100; / * this statement will cause a compiler error Since

IT WAS Not Declared at the top of the function. * /

/ * This statement will result in a compiler error,

Because it is not declared at the top of the function. * /

Printf ("J:% D ​​/ N", J);

}

(b). / * Whereas this code will not * /

/ * And this code will not produce a compiler error * /

Void main (void)

{

INT i = 10;

Printf ("i:% d / n", i);

{

INT J = 100; / * this statement is fine since it is akin

TO Defining a local function within the function. * /

/ * This statement is very refined,

Because it defines a part of a partial function in a function. * /

Printf ("J:% D ​​/ N", J);

}

}

转载请注明原文地址:https://www.9cbs.com/read-22662.html

New Post(0)