Skip to content

Fix Windows build: ReplaceText GDI macro conflict and generation script issues - #756

Open
weiliguo wants to merge 4 commits into
quickfix:masterfrom
weiliguo:fix/windows-generation-build
Open

weiliguo wants to merge 4 commits into
quickfix:masterfrom
weiliguo:fix/windows-generation-build

Conversation

@weiliguo

Copy link
Copy Markdown

Summary

Three small fixes that together make the C++ generation workflow work on Windows
and produce outputs that compile with MSVC.

Changes

1. Fix spec/generate.bat for jruby 10 on Windows

jruby 10 no longer prepends the script directory to $LOAD_PATH, so
require "Processor" fails with LoadError. Added -I. to both jruby
and MRI invocations — consistent with generate.sh which already had it.

Also replaced jruby -h with jruby --version. The -h flag uses cat
as a pager, which does not exist on Windows and crashes the batch script.

2. Align spec/generate_c++.bat with generate_c++.sh

The shell version generated FixValues.h from FIX50SP2.xml but the
Windows batch version was still using FIX50.xml. Unified on FIX50SP2.xml
so both platforms produce identical outputs.

3. Fix GeneratorCPP.rb to emit MSVC-compatible ReplaceText guards

The FIX 5.0SP2 ReplaceText field collides with the ReplaceText macro
defined by Windows GDI (wingdi.h). Upstream manually patched the generated
.h files in commit ee190f8 but did not fix the generator, so any
regeneration silently dropped the fix.

Added pushReplaceText / popReplaceText helper methods that emit
_MSC_VER-conditional #pragma push_macro / pop_macro guards for both
FixFields.h and FixFieldNumbers.h. Previously FixFieldNumbers.h had
no ReplaceText guard at all.

Regenerated the affected files with the fixed scripts on Windows (jruby 10).
Output on Linux (MRI/jruby) is byte-identical.

Testing

  • Ran spec/generate.bat on Windows, confirmed no diff against committed output
  • Ran cmake --build build with MSVC 2022, confirmed FixFields.h / FixFieldNumbers.h
    compile without macro-collision errors

Related

Fixes #530

jruby 10 (Ruby 4.0 mode) no longer prepends the script directory
to \, so require 'Processor' in Generator.rb fails with
LoadError. Add '-I.' to both jruby and MRI invocations.

Also replace 'jruby -h' with 'jruby --version' because -h invokes
'cat' as a pager, which does not exist on Windows and crashes with
java.io.IOException. --version prints the version string and exits 0.
The shell version already generates FixValues.h from FIX50SP2.xml
but the Windows batch version was still using FIX50.xml. FIX50SP2
is the final service pack and contains all FIX 5.0 fields, so both
platforms should produce identical output.
… outputs

The FIX 5.0SP2 ReplaceText field collides with the ReplaceText macro
defined by Windows GDI (wingdi.h). Upstream manually patched the
generated .h files in commit ee190f8 but did not fix GeneratorCPP.rb,
so any regeneration would silently drop the fix.

Add pushReplaceText/popReplaceText helper methods to GeneratorCPP.rb
that emit _MSC_VER-conditional #pragma push_macro/pop_macro guards
for both FixFields.h and FixFieldNumbers.h. Previously FixFieldNumbers.h
had no ReplaceText guard at all.

Regenerate all affected files with the fixed scripts (jruby 10 on
Windows): this also corrects several latent ordering/naming issues in
the committed files caused by the old MRI/jruby Hash iteration order.
Notably, QuoteAckStatus (field 1865) is now correctly separated from
QuoteStatus (field 297), and fix42/QuoteAcknowledgement.h now
correctly references QuoteStatus instead of QuoteAckStatus.

Fixes quickfix#530
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FixFieldNumbers.h - ReplaceText

1 participant