Project

General

Profile

Actions

Backport #2234

closed

Macros defined in win32.h cause some code to fail to compile.

Added by tstephen (Thomas Stephens) over 14 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
[ruby-core:26166]

Description

=begin
The Windows-only win32.h defines some macros which map Microsoft's _foo functions to functions of the same name, but without the underscore. By making these macros, there is a possibility that the preprocessor can perform macro-substitution where it was not intended.

As an example, consider this macro definition in win32.h:
#ifndef finite
#define finite(x) _finite(x)
#endif

Given the attached example code, when the struct's member variable, finite, is initialized in the initializer list, the preprocessor interprets finite(0) as a call to the macro, finite(x), and replaces it with _finite(0). The C++ compiler then attempts to initialize the member, _finite, to 0, and there is a compilation error (because the struct does not have a member named _finite).

Please consider replacing these macros with inline functions. The resulting assembled code should be equivalent, and the inline function both preserves type-safety and prevents namespace polution.
=end


Files

ruby_struct_test.cpp (208 Bytes) ruby_struct_test.cpp tstephen (Thomas Stephens), 10/20/2009 01:23 AM
Actions #1

Updated by naruse (Yui NARUSE) over 14 years ago

  • Status changed from Open to Closed

=begin
Fixed by r25408
=end

Actions

Also available in: Atom PDF

Like0
Like0