Fix: Avoid windows.h min/max macro definition in BLI_winstuff.h #108471

Merged
Jacques Lucke merged 3 commits from guishe/blender:expected-type into main 2023-06-01 12:26:40 +02:00
Contributor

When moving io_allembic to c++, the compiler would throw the error
type "unknown-type" unexpected.

When moving io_allembic to c++, the compiler would throw the error `type "unknown-type" unexpected`.
Iliya Katushenock requested review from Jacques Lucke 2023-05-31 18:33:47 +02:00
Author
Contributor

Here the compiler output

image

Here the compiler output ![image](/attachments/9b10143e-5068-4bf3-8dee-1dbcd160bca2)

Hey, are you sure is that is really caused by template parametr?
I was get same errors due to macros leak from windows.h.

Hey, are you sure is that is really caused by template parametr? I was get same errors due to macros leak from `windows.h`.
Iliya Katushenock changed title from Fix : Add missign type specification to Cleanup: Add missing template argument 2023-05-31 18:38:38 +02:00
Author
Contributor

You're right!

Specifying the template parameter removes the ambiguity.

Another solution is to use

#undef min
#undef max

And we could remove the template argument specification that was made in other lines in the same files

You're right! Specifying the template parameter removes the ambiguity. Another solution is to use ``` #undef min #undef max ``` And we could remove the template argument specification that was made in other lines in the same files
Member

Do you have a repro to get the error? I'd like to take a closer look what's happening there

Do you have a repro to get the error? I'd like to take a closer look what's happening there

You should probably start a PR so that others can see it. As a result of my attempts to get around the leak, I realized that it's easier to just create a new C++ file.

You should probably start a PR so that others can see it. As a result of my attempts to get around the leak, I realized that it's easier to just create a new C++ file.
Author
Contributor

Here the pr #108477

The error comes when moving io_allembic to .cc

With this uncommented also compile

image

Here the pr https://projects.blender.org/blender/blender/pulls/108477 The error comes when moving `io_allembic` to .cc With this uncommented also compile ![image](/attachments/03764ff3-9671-4384-ba85-208378d3f5f9)
Member

That's a Band-Aid, not a fix, all inclusions that lead to windows.h being included, have been guarded with the appropriate macro's to prevent windows.h from defining min/max.

What needs to be done here is find who/what drags in windows.h and put these same guards around that.

That's a Band-Aid, not a fix, all inclusions that lead to `windows.h` being included, have been [guarded](https://projects.blender.org/blender/blender/src/branch/main/source/blender/blenlib/BLI_enumerable_thread_specific.hh#L9) with the appropriate macro's to prevent `windows.h` from defining min/max. What needs to be done here is find who/what drags in windows.h and put these same guards around that.

If you want, you can continue my attempt 7d1e58f12b (i was get error in index range actually)

If you want, you can continue my attempt https://projects.blender.org/blender/blender/commit/7d1e58f12b607c1321a114f7a668b4522d650af9 (i was get error in index range actually)
Guillermo Venegas force-pushed expected-type from 3830316c4f to 8e6a1b9e3e 2023-05-31 21:08:49 +02:00 Compare
Author
Contributor

Was the #include <windows.h> on BLI_winstuff.h

Was the `#include <windows.h>` on `BLI_winstuff.h`
Guillermo Venegas changed title from Cleanup: Add missing template argument to Fix: Avoid windows.h min/max macro specification in BLI_winstuff.h 2023-05-31 21:14:40 +02:00
Author
Contributor

I modified the patch to avoid including the macros by doing #include <windows.h> in BLI_winstuff.h

@mod_moder I took a look, its the same fix needed in 7d1e58f12b

I modified the patch to avoid including the macros by doing `#include <windows.h>` in `BLI_winstuff.h` @mod_moder I took a look, its the same fix needed in https://projects.blender.org/blender/blender/commit/7d1e58f12b607c1321a114f7a668b4522d650af9
Guillermo Venegas changed title from Fix: Avoid windows.h min/max macro specification in BLI_winstuff.h to Fix: Avoid windows.h min/max macro definition in BLI_winstuff.h 2023-05-31 22:40:21 +02:00
Ray molenkamp requested changes 2023-06-01 00:58:43 +02:00
@ -17,6 +17,10 @@
#define WIN32_LEAN_AND_MEAN
#ifndef NOMINMAX
Member

this has to be done the same way as I linked, including cleanup

this has to be done the same way as I linked, including cleanup
guishe marked this conversation as resolved
@ -54,3 +58,3 @@
# define W_OK 2
/* Not accepted by `access()` on windows. */
//# define X_OK 1
// # define X_OK 1
Member

unintended whitespace change?

unintended whitespace change?
guishe marked this conversation as resolved
Guillermo Venegas force-pushed expected-type from 8e6a1b9e3e to ef6b5db997 2023-06-01 01:39:54 +02:00 Compare
Guillermo Venegas reviewed 2023-06-01 01:45:58 +02:00
@ -18,3 +18,3 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#if defined(WIN32) && !defined(NOMINMAX)
Author
Contributor

defined(WIN32) It ends up being redundant because BLI_winstuff.h should only be imported on windows I think

`defined(WIN32)` It ends up being redundant because `BLI_winstuff.h` should only be imported on windows I think
Member

there's a check that errors if it's not WIN32 a few lines above that , so defined(WIN32) this can be safely removed.

there's a check that errors if it's not WIN32 a few lines above that , so `defined(WIN32)` this can be safely removed.
guishe marked this conversation as resolved
Guillermo Venegas requested review from Ray molenkamp 2023-06-01 01:49:08 +02:00
Guillermo Venegas added 1 commit 2023-06-01 02:44:33 +02:00
Author
Contributor

Done!

Done!
Ray molenkamp approved these changes 2023-06-01 06:12:22 +02:00
Ray molenkamp left a comment
Member

lgtm , @JacquesLucke feel free to land, I didn't want to land it and go awol for 8+ hours

lgtm , @JacquesLucke feel free to land, I didn't want to land it and go awol for 8+ hours

At first it seemed to me to be Jacques scope (templates and containers of bli), but when it turned out to be the Dodo's scope, it turned out that I could not delete the reviewer

At first it seemed to me to be Jacques scope (templates and containers of bli), but when it turned out to be the Dodo's scope, it turned out that I could not delete the reviewer
Jacques Lucke approved these changes 2023-06-01 12:25:50 +02:00
Jacques Lucke merged commit f957fd227e into main 2023-06-01 12:26:40 +02:00
Guillermo Venegas deleted branch expected-type 2023-06-01 13:46:02 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#108471
No description provided.