小编Iva*_*eia的帖子

#error directive in C. How to display some #define

I need to display some relevant information in #error preprocessor directive. For example:

#define myConstant 5

#if myConstant > 10
    #error myConstant has to be > 10, now %d  //should display "5"
#endif
Run Code Online (Sandbox Code Playgroud)

How can I do that?

c debugging

10
推荐指数
1
解决办法
111
查看次数

C语言转换不清楚

我很惊讶为什么得到不同的结果。

    uint16_t wCaptureTime = 35;

    wDeltaTime1 = (uint16_t) - (int16_t)wCaptureTime;
    wDeltaTime2 =  0xFFFF - (int16_t)wCaptureTime;

    printf("wDeltaTime1 %d \n", wDeltaTime1);
    printf("wDeltaTime2 %d \n", wDeltaTime2);
Run Code Online (Sandbox Code Playgroud)

该代码导致:

wDeltaTime1 65501 
wDeltaTime2 65500 
Run Code Online (Sandbox Code Playgroud)

有人可以解释或提供一些链接以了解该行为。

c casting

0
推荐指数
1
解决办法
94
查看次数

标签 统计

c ×2

casting ×1

debugging ×1