win64 · Шаг 8. Журнал изменений кода ради 64 бит
Это полный человекочитаемый журнал ВСЕХ правок кода, выполненных при портировании
TMC Suite на 64 бита (платформа x64). Источник — раздел «Портирование на win64»
журнала ISSUES.md. Без этого журнала 64‑битная сборка была бы невоспроизводима.
Для каждой правки указаны: файл и место, что было, что стало, почему это 64‑битная проблема, и подтверждение, что математика/физика расчётов не изменена.
Общий принцип портирования: чиним только разрядность. Математику расчётов не трогаем. На win32 все эти правки нейтральны: типы
INT_PTRиUINT_PTRсовпадают сintиUINT, поэтому поведение 32‑битной версии не меняется.Обозначения: П‑N — правки, относящиеся к разрядности (portability). Ф4‑N и П‑3 — правки, формально вызванные современным компилятором; они нужны и для win32, и для win64 (отмечено отдельно).
Сводная таблица
| Пункт | Суть | Где (фаза) | Чисто 64‑бит? |
|---|---|---|---|
| Фаза 1 | Правок кода не потребовалось | библиотеки | — |
| П‑1 | DoModal(): int → INT_PTR |
вьюверы (Ф2), FieldView (Ф4) | да |
| П‑2 | OnTimer(UINT) → OnTimer(UINT_PTR) |
вьюверы (Ф2), FieldView (Ф4) | да |
| П‑3 | outp/inp → Beep() |
ядра H и X (Ф3) | нет (и win32) |
| Ф4‑1 | удалён #include <gl\glaux.h>, убран glaux.lib |
FieldView (Ф4) | нет (и win32) |
Фаза 1 (библиотеки) — правок кода НЕ потребовалось
При сборке всех 6 библиотек под x64 правок кода ради 64 бит не понадобилось.
Все библиотеки скомпилировались под x64 чисто — только обычные легаси‑предупреждения
(C4996 небезопасные CRT, C4267 size_t→short, C4700 неинициализированная
переменная), те же, что и в win32. На разрядность они не влияют.
Изменения коснулись только конфигурации сборки (не код):
- В 5 проектов (complex, exprint, TMCLibError, Prepr, TMCIndan) добавлены конфигурации
Debug|x64иRelease|x64— зеркально win32 (toolsetv145,UseOfMfcиRuntimeLibraryкак в win32‑конфигурациях). У SFILE95 x64‑конфигурации уже были. - Вывод
.libвdist\win64\libидёт автоматически черезbuild\LibOutput.props($(Platform)=x64→PlatformFolder=win64).
Вывод: 64‑битные проблемы сосредоточены во вьюверах, ядрах и FieldView (Фазы 2–4), а не в библиотеках.
П‑1: DoModal() возвращает int вместо INT_PTR
- Ошибка компилятора:
C2555— возвращаемый тип переопределённой виртуальной функцииDoModalотличается от базовогоCDialog::DoModalи не ковариантен. - Почему это 64‑битная проблема: в современной (64‑битной) MFC базовый
CDialog::DoModal()(а такжеCPropertySheet::DoModal()) возвращаетINT_PTR— это 64‑битный целочисленный тип на x64. Старый код объявлялint DoModal(). На win32INT_PTRтождественноint, поэтому раньше всё компилировалось; на win64 типы расходятся (int— 4 байта,INT_PTR— 8 байт) → несовпадение сигнатуры override. - Что было:
cpp
virtual int DoModal();
// ...
int C...::DoModal() { /* тело без изменений */ }
- Что стало:
cpp
virtual INT_PTR DoModal();
// ...
INT_PTR C...::DoModal() { /* тело без изменений */ }
- Где именно (по файлам):
- TMCROS (
src\viewers\Tmcrtout):DialogDoc.h/.cpp,DialogTtoS.h/.cpp,TmcGrParColTypWid.h/.cpp. - TMCGROUT (
src\viewers\Tmcgrout):TmcGrParColTypWid.h/.cpp,TMCGROUTDIALOGView.h/.cpp. - TMC_DN (
src\viewers\DiaNapGr):DialogTtoS.h/.cpp,ThreadCalcDirPat.h/.cpp,TmcGrParColTypWid.h/.cpp. - FieldView (
src\fieldview):TMCDialogPropet.h(объявление) иTMCDialogPropet.cpp(определение) — overrideCPropertySheet::DoModal. Внимание:CTmcASetColor::DoModal(COLORREF*)не трогался — у него своя сигнатура с аргументом, это не override базовогоDoModal(). - Совместимость с win32: полная (
INT_PTR ≡ intв 32 бит) — поведение не меняется. - Математика расчётов не затронута: да (изменён только тип возврата диалоговой функции MFC).
- git‑коммит: —
- Статус: исправлено.
Применено в шагах:
04-build-viewers.md(вьюверы) и06-build-fieldview.md(FieldView).
П‑2: обработчик таймера OnTimer(UINT) вместо OnTimer(UINT_PTR)
- Ошибка компилятора:
C2440/C2737— в карте сообщенийON_WM_TIMERнельзя привестиvoid (CView::*)(UINT)к ожидаемомуvoid (CWnd::*)(UINT_PTR). - Почему это 64‑битная проблема: в 64‑битной MFC сигнатура
CWnd::OnTimer—OnTimer(UINT_PTR nIDEvent)(идентификатор таймера хранит указатель, поэтому типUINT_PTR). Старый код объявлялOnTimer(UINT). На win32UINT_PTR ≡ UINT— компилировалось; на win64 — несовпадение типа параметра в макросе карты сообщений. - Что было:
cpp
afx_msg void OnTimer(UINT nIDEvent);
// ...
void C...View::OnTimer(UINT nIDEvent) { /* тело без изменений */ }
- Что стало:
cpp
afx_msg void OnTimer(UINT_PTR nIDEvent);
// ...
void C...View::OnTimer(UINT_PTR nIDEvent) { /* тело без изменений */ }
- Где именно (по файлам):
- TMCROS:
TMCGROUTView.h/.cpp. - TMCGROUT:
TMCGROUTView.h/.cpp. - TMC_DN:
TMCGROUTView.h/.cpp,ThreadCalcDirPat.h/.cpp. - FieldView:
FldViewView.h/.cpp. - Совместимость с win32: полная (
UINT_PTR ≡ UINTв 32 бит). - Математика расчётов не затронута: да (изменён только тип идентификатора таймера).
- git‑коммит: —
- Статус: исправлено.
Применено в шагах:
04-build-viewers.md(вьюверы) и06-build-fieldview.md(FieldView).
П‑3: прямой доступ к портам ввода‑вывода outp()/inp() (звук на Windows 95)
Эта правка не является чисто 64‑битной — имена
outp/inpудалены и для x86. Правка одинакова и нужна и для win32, и для win64. Внесена в журнал портирования, потому что напрямую связана с невозможностью прямого доступа к портам на x64.
- Файл и место:
kernels\PlanarRT_H\PL_GLFUN.CPPиkernels\PlanarRT_X\Pl_glfun.cpp, функцияs_tone(int freq, int time)(генерация звукового сигнала), строки ~558–568. - Ошибка / симптом:
error C3861: 'outp'/'inp': идентификатор не найден(и после замены на_outp/_inp— то же). Современный MSVC (v145) удалил интринсики прямого доступа к портам_inp/_outpиз<conio.h>. На x64 прямой доступ к портам в/в в принципе невозможен — это привилегированные инструкции, запрещённые в пользовательском режиме. - Что было: в ветке
if( bIsSysten_W95 )— прямое программирование системного таймера 8253 (порты0x42/0x43) и порта динамика0x61:
cpp
outp(67, ...); outp(66, ...);
inp(97); outp(97, ...);
- Что стало: тело ветки заменено на резервный вызов:
cpp
Beep( freq, time ); // + подавление предупреждений о неиспользуемых
// divisor / port_buff
- Почему это безопасно: ветка
bIsSysten_W95достижима только на Windows 95. Выше по коду веткаif( bIsSysten_WNT )уже делаетBeep()иreturn— на любой NT‑системе (Windows 7+, где вообще запускается сборка) управление до W95‑ветки не доходит. Поведение на реальном Windows 95 нерелевантно. Частоты звука вычисляются как раньше. - Математика расчётов не затронута: да (это код звукового сигнала, не физика).
- git‑коммит: —
- Статус: исправлено. После правки tmc_rth и tmc_rtx собираются под Win32 и x64 без ошибок.
Применено в шаге
05-build-kernels.md(оба ядра, обе платформы).
Ф4‑1: мёртвый #include <gl\glaux.h> (GLAUX удалён из современного SDK)
Эта правка не является чисто 64‑битной — GLAUX отсутствует и для x86. Нужна и для win32, и для win64. Включена сюда, поскольку относится к подготовке FieldView к современному SDK, выполняемой при 64‑битной сборке.
- Файл и место:
src\fieldview\TmcGLText.h, строка 12 (заголовок классаCTmcGLText). - Ошибка / симптом:
C1083—gl\glaux.hне найден (и нетglaux.lib). GLAUX — устаревшая вспомогательная библиотека OpenGL, отсутствует в современном Windows SDK. - Что было:
cpp
#include <gl\glaux.h>
- Что стало: include удалён (заменён комментарием). В коде не используется ни одна
aux*‑функция: текст рисуется через GDI (CreateFontIndirect,GetDIBits) и ядро OpenGL (glBitmap,glRasterPos3f). Из линкера убранglaux.lib. - Математика расчётов не затронута: да.
- git‑коммит: —
- Статус: исправлено.
Применено в шаге
06-build-fieldview.md.
Контрольная сверка с ISSUES.md
Все записи раздела «Портирование на win64» из ISSUES.md перенесены сюда:
- [x] Фаза 1 (библиотеки) — правок кода не потребовалось, только x64‑конфигурации.
- [x] П‑1 —
DoModal()→INT_PTR(вьюверы + FieldView). - [x] П‑2 —
OnTimer(UINT)→OnTimer(UINT_PTR)(вьюверы + FieldView). - [x] П‑3 —
outp/inp→Beep()(ядра H и X; нужна и для win32). - [x] Ф4‑1 — удалён
#include <gl\glaux.h>, убранglaux.lib(FieldView; нужна и для win32).
Ни одно изменение из журнала ISSUES.md не потеряно.
Чек‑лист «что уточнить»
- [ ] git‑коммиты для правок П‑1, П‑2, П‑3, Ф4‑1 — в
ISSUES.mdне зафиксированы (стоит «—»). При наличии истории добавить хеши.
win64 · Step 8. Log of code changes made for 64 bits
This is the complete human-readable log of ALL code changes made while porting TMC Suite to
64 bits (platform x64). The source is the "Porting to win64" section of the ISSUES.md
log. Without this log the 64-bit build would be non-reproducible.
For each change the following are given: the file and location, what it was, what it became, why it is a 64-bit problem, and confirmation that the computation math/physics was not changed.
The general porting principle: fix only bitness. Do not touch the computation math. On win32 all these changes are neutral: the types
INT_PTRandUINT_PTRcoincide withintandUINT, so the behavior of the 32-bit version does not change.Notation: P-N — changes related to bitness (portability). F4-N and P-3 — changes formally caused by the modern compiler; they are needed for both win32 and win64 (noted separately).
Summary table
| Item | Essence | Where (phase) | Purely 64-bit? |
|---|---|---|---|
| Phase 1 | No code changes needed | libraries | — |
| P-1 | DoModal(): int -> INT_PTR |
viewers (Ph2), FieldView (Ph4) | yes |
| P-2 | OnTimer(UINT) -> OnTimer(UINT_PTR) |
viewers (Ph2), FieldView (Ph4) | yes |
| P-3 | outp/inp -> Beep() |
kernels H and X (Ph3) | no (win32 too) |
| F4-1 | removed #include <gl\glaux.h>, removed glaux.lib |
FieldView (Ph4) | no (win32 too) |
Phase 1 (libraries) — NO code changes were needed
When building all 6 libraries for x64, no code changes for 64 bits were needed. All
libraries compiled cleanly under x64 — only the usual legacy warnings (C4996 unsafe CRT,
C4267 size_t->short, C4700 uninitialized variable), the same as in win32. They do not
affect bitness.
The changes affected only the build configuration (not code):
- In 5 projects (complex, exprint, TMCLibError, Prepr, TMCIndan) the configurations
Debug|x64andRelease|x64were added — mirroring win32 (toolsetv145,UseOfMfcandRuntimeLibraryas in the win32 configurations). SFILE95 already had the x64 configurations. .liboutput todist\win64\libgoes automatically viabuild\LibOutput.props($(Platform)=x64->PlatformFolder=win64).
Conclusion: the 64-bit problems are concentrated in the viewers, kernels and FieldView (Phases 2–4), not in the libraries.
P-1: DoModal() returns int instead of INT_PTR
- Compiler error:
C2555— the return type of the overridden virtual functionDoModaldiffers from the baseCDialog::DoModaland is not covariant. - Why it is a 64-bit problem: in the modern (64-bit) MFC the base
CDialog::DoModal()(andCPropertySheet::DoModal()) returnsINT_PTR— a 64-bit integer type on x64. The old code declaredint DoModal(). On win32INT_PTRis identical toint, so it compiled before; on win64 the types diverge (int— 4 bytes,INT_PTR— 8 bytes) -> an override signature mismatch. - What it was:
cpp
virtual int DoModal();
// ...
int C...::DoModal() { /* body unchanged */ }
- What it became:
cpp
virtual INT_PTR DoModal();
// ...
INT_PTR C...::DoModal() { /* body unchanged */ }
- Exactly where (by file):
- TMCROS (
src\viewers\Tmcrtout):DialogDoc.h/.cpp,DialogTtoS.h/.cpp,TmcGrParColTypWid.h/.cpp. - TMCGROUT (
src\viewers\Tmcgrout):TmcGrParColTypWid.h/.cpp,TMCGROUTDIALOGView.h/.cpp. - TMC_DN (
src\viewers\DiaNapGr):DialogTtoS.h/.cpp,ThreadCalcDirPat.h/.cpp,TmcGrParColTypWid.h/.cpp. - FieldView (
src\fieldview):TMCDialogPropet.h(declaration) andTMCDialogPropet.cpp(definition) — override ofCPropertySheet::DoModal. Note:CTmcASetColor::DoModal(COLORREF*)was not touched — it has its own signature with an argument; it is not an override of the baseDoModal(). - Compatibility with win32: full (
INT_PTR ≡ intin 32-bit) — the behavior does not change. - Computation math not affected: yes (only the return type of an MFC dialog function was changed).
- Status: fixed.
Applied in steps:
04-build-viewers.md(viewers) and06-build-fieldview.md(FieldView).
P-2: timer handler OnTimer(UINT) instead of OnTimer(UINT_PTR)
- Compiler error:
C2440/C2737— in theON_WM_TIMERmessage map, avoid (CView::*)(UINT)cannot be cast to the expectedvoid (CWnd::*)(UINT_PTR). - Why it is a 64-bit problem: in 64-bit MFC the signature of
CWnd::OnTimerisOnTimer(UINT_PTR nIDEvent)(the timer identifier holds a pointer, hence theUINT_PTRtype). The old code declaredOnTimer(UINT). On win32UINT_PTR ≡ UINT— it compiled; on win64 there is a parameter-type mismatch in the message-map macro. - What it was:
cpp
afx_msg void OnTimer(UINT nIDEvent);
// ...
void C...View::OnTimer(UINT nIDEvent) { /* body unchanged */ }
- What it became:
cpp
afx_msg void OnTimer(UINT_PTR nIDEvent);
// ...
void C...View::OnTimer(UINT_PTR nIDEvent) { /* body unchanged */ }
- Exactly where (by file):
- TMCROS:
TMCGROUTView.h/.cpp. - TMCGROUT:
TMCGROUTView.h/.cpp. - TMC_DN:
TMCGROUTView.h/.cpp,ThreadCalcDirPat.h/.cpp. - FieldView:
FldViewView.h/.cpp. - Compatibility with win32: full (
UINT_PTR ≡ UINTin 32-bit). - Computation math not affected: yes (only the type of the timer identifier was changed).
- Status: fixed.
Applied in steps:
04-build-viewers.md(viewers) and06-build-fieldview.md(FieldView).
P-3: direct I/O port access outp()/inp() (sound on Windows 95)
This change is not purely 64-bit — the names
outp/inpare removed for x86 too. The change is identical and needed for both win32 and win64. It is in the porting log because it is directly related to the impossibility of direct port access on x64.
- File and location:
kernels\PlanarRT_H\PL_GLFUN.CPPandkernels\PlanarRT_X\Pl_glfun.cpp, the functions_tone(int freq, int time)(sound-signal generation), lines ~558–568. - Error / symptom:
error C3861: 'outp'/'inp': identifier not found(and after replacing with_outp/_inp— the same). The modern MSVC (v145) removed the intrinsics for direct port access_inp/_outpfrom<conio.h>. On x64, direct I/O port access is impossible in principle — these are privileged instructions forbidden in user mode. - What it was: in the
if( bIsSysten_W95 )branch — direct programming of the system 8253 timer (ports0x42/0x43) and the speaker port0x61:
cpp
outp(67, ...); outp(66, ...);
inp(97); outp(97, ...);
- What it became: the branch body was replaced with a fallback call:
cpp
Beep( freq, time ); // + suppression of warnings about unused
// divisor / port_buff
- Why it is safe: the
bIsSysten_W95branch is reachable only on Windows 95. Earlier in the code theif( bIsSysten_WNT )branch already doesBeep()andreturn— on any NT system (Windows 7+, where the build runs at all) control never reaches the W95 branch. Behavior on a real Windows 95 is irrelevant. The sound frequencies are computed as before. - Computation math not affected: yes (this is sound-signal code, not physics).
- Status: fixed. After the change tmc_rth and tmc_rtx build for Win32 and x64 without errors.
Applied in step
05-build-kernels.md(both kernels, both platforms).
F4-1: dead #include <gl\glaux.h> (GLAUX removed from the modern SDK)
This change is not purely 64-bit — GLAUX is absent for x86 too. It is needed for both win32 and win64. Included here because it relates to preparing FieldView for the modern SDK, done during the 64-bit build.
- File and location:
src\fieldview\TmcGLText.h, line 12 (the header of the classCTmcGLText). - Error / symptom:
C1083—gl\glaux.hnot found (and there is noglaux.lib). GLAUX is an obsolete OpenGL helper library, absent from the modern Windows SDK. - What it was:
cpp
#include <gl\glaux.h>
- What it became: the include was removed (replaced with a comment). No
aux*function is used in the code: text is drawn via GDI (CreateFontIndirect,GetDIBits) and core OpenGL (glBitmap,glRasterPos3f).glaux.libwas removed from the linker. - Computation math not affected: yes.
- Status: fixed.
Applied in step
06-build-fieldview.md.
Cross-check against ISSUES.md
All entries of the "Porting to win64" section of ISSUES.md are carried over here:
- [x] Phase 1 (libraries) — no code changes needed, only x64 configurations.
- [x] P-1 —
DoModal()->INT_PTR(viewers + FieldView). - [x] P-2 —
OnTimer(UINT)->OnTimer(UINT_PTR)(viewers + FieldView). - [x] P-3 —
outp/inp->Beep()(kernels H and X; needed for win32 too). - [x] F4-1 — removed
#include <gl\glaux.h>, removedglaux.lib(FieldView; needed for win32 too).
No change from the ISSUES.md log is lost.