简体   繁体   English

为什么在使用WinAPI:COLORREF / RGB时,GCC不会报告任何错误或警告?

[英]Why GCC doesn't report any errors or warnings when using WinAPI: COLORREF/RGB?

The correct usage is: 正确的用法是:

COLORREF COLOR = RGB (255,255,255);

However, This 但是,这

COLORREF COLOR = (255,255,255);

can be compiled without any warnings or errors. 可以编译而没有任何警告或错误。

Why? 为什么? So strange? 这么奇怪? Thanks. 谢谢。

Reference: 参考:

  1. COLORREF COLORREF

  2. RGB() RGB()

The type COLORREF is a typedef for a DWORD . 类型COLORREFDWORD的typedef。 The line 线

COLORREF COLOR = (255,255,255);

is equivalent to 相当于

DWORD COLOR = 255;

and therefore compiles fine. 因此编译良好。 It may not do what you want however. 但是,它可能无法满足您的要求。

The reason is that expr1, expr2 yields the value of expr2 in C, so 255, 255, 255 has a value of 255 . 其原因是, expr1, expr2得到的值expr2在C,所以255, 255, 255具有值255 The brackets have no effect here. 括号在这里无效。 See: 看到:

http://en.wikipedia.org/wiki/Comma_operator http://en.wikipedia.org/wiki/Comma_o​​perator

Note that the RGB macro itself just makes the appropriate DWORD (some number) from red, green and blue components. 请注意,RGB宏本身只是根据红色,绿色和蓝色分量生成适当的DWORD (一些数字)。 Numbers essentially are COLORREFs here. 在这里,数字本质上 COLORREF。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么GCC不会在文件末尾生成有关换行符的任何警告? - Why GCC doesn't generate any warnings about newline at end of file? 为什么 GCC 只有在使用结构名称而不是 typedef 时才会抛出错误和不必要的警告? - Why is GCC make throwing errors and uneccesary warnings only when using the struct name instead of typedef? 魔术 COLORREF/RGB 值来确定何时使用浅色/深色文本 - Magic COLORREF/RGB value to determine when to use light/dark text VSCode 不显示所有警告/错误 - VSCode doesn't show all warnings/errors gcc -O3标志会导致-O2不会发出警告 - gcc -O3 flag causes warnings that -O2 doesn't 为什么fabs()在使用GCC进行编译时不需要-lm选项 - Why fabs() doesn't require the -lm option when compiling with GCC 为什么我的程序没有显示任何 output? 0 个错误,0 个警告但没有 output? 我正在使用 Dev C++ 编译器 - Why is my program not showing any output? 0 errors, 0 warnings but no output? I'm using Dev C++ compiler 为什么海湾合作委员会不这样? - Why doesn't GCC like this? 在 winapi c 中使用句柄,返回 0 并且没有错误,但它没有打印任何文件 - Using handle in winapi c, return with 0 and no errors but it's not printing any file 为什么 gcc 仅在 SS/SD 指令中使用较低值时不将 XMM 寄存器的较高值归零? - Why doesn't gcc zero the upper values of an XMM register when only using the lower value with SS/SD instructions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM