Comments (15)
Yes, you're right, I see now! Will test on Monday.
from replxx.
Hello.
I have put those #undefs explicitly because either replxx or some replxx client did not build on Windows.
You are right, #undef in replxx.h is unnecessary (and will be removed).
from replxx.
Sorry, that wasn't quite my point. The Windows SDK creates the following definitions:
WinNT.h
// The following are masks for the predefined standard access types
#define DELETE (0x00010000L)
WinGDI.h
/* Region Flags */
#define ERROR 0
So the issue is that, yes, if replxx wants to use those tokens it can undefine them, but then they're not available to client code that's included those headers. That's why locally I've renamed those two entities in replxx. It's a breaking change to replxx, but I can't see a way for it to keep those entity names, and still let client code access those values from the Windows SDK.
I mean, it's up to you. I'm happy to keep local changes for those lines — I have another couple of local tweaks anyway¹, I just thought I ought to mention it.
¹ — which I may raise as enhancement reqs. a little later. One is to add declspec tags to allow use in a Windows DLL; the other is a shut-down problem that I have to investigate bit more, to see whether the issue I've fixed is unique to our codebase or more common. Actually, there's a third issue about use in a Windows GUI app that creates its own console window. I may raise the simple two shortly.
from replxx.
Do you actually use directly ERROR or DELETE from Windows headers?
from replxx.
Yes, that's how we found the issue.
That said, I think only ERROR caused a problem for us, then while looking for it I saw the DELETE one.
from replxx.
Honestly, I don't have an axe to grind, you can resolve this as you see fit — I've patched it locally, I'm just letting you know as it's technically wrong.
But then so is riddling system headers with #defines covering common keywords.
from replxx.
Thank you for your report.
Unfortunately I cannot in good conscience rename those conflicting identifiers
as the error is in my opinion in Windows headers.
With current approach replxx is at least usable on Windows without changes in the library code,
though as you report there are cases when client code breaks.
BTW
If I had encountered it myself I would probably try fix it by something like:
#ifdef ERROR
enum { ERROR_VAL = ERROR };
#undef ERROR
enum { ERROR = ERROR_VAL };
#endif
Before including replxx.hxx
header.
from replxx.
If the code above would fix it in your case I am ready to put this code into replxx.hxx
header
from replxx.
It does look like that should resolve the ERROR issue, I'll try it later.
Not sure about DELETE (which, as I said, I don't think we've hit), as I suspect it has to have your specific value for key matching? I can't check the code ATM.
That macro does feel more esoteric, though.
from replxx.
Actually, no, don't do that: ERROR is defined in Windows to be 0, so the replxx ERROR/ERROR_VAL would then be zero and clash with BLACK.
from replxx.
Well I do not know what you mean.
I see no way for my workaround to clash with BLACK
.
I want to place the workaround code at the very top of replxx.hxx
header.
I mean before namespace replxx {
line.
And by workaround code I mean code with enum
trick.
Can you please check if adding this code (where I said) fixes the issue for you?
from replxx.
BLACK is zero.
#ifdef ERROR
enum { ERROR_VAL = ERROR }; // sets ERROR_VAL = 0
#undef ERROR
enum { ERROR = ERROR_VAL }; // sets ERROR = 0
#endif
Now ERROR == BLACK == 0. Is that not going to cause problems?
from replxx.
With proposed fix only ERROR
from global namespace is 0
, Replxx::Color::ERROR
is -2
.
Can you please actually test if my solution fixes the problem for you?
from replxx.
(I'm not normally that dense, honest!)
from replxx.
I final got someone to test that fix against our SW (it's in a sub-system I'm not involved with). It does fix the problem, but with a caveat: I was wrong earlier in that it's DELETE that caused us a problem, not ERROR. So, I just replicated your fix above for that.
For completeness, my local copy of replxx.hxx now has the following, with the undefs removed, and it works (Linux [RHEL7] and Windows [VS2015]):
#ifdef ERROR
enum { ERROR_VAL = ERROR }; // sets ERROR_VAL = 0
#undef ERROR
enum { ERROR = ERROR_VAL }; // sets ERROR = 0
#endif
#ifdef DELETE
enum { DELETE_VAL = DELETE }; // sets DELETE_VAL = 0
#undef DELETE
enum { DELETE = DELETE_VAL }; // sets DELETE = 0
#endif
from replxx.
Related Issues (20)
- error: debug map object file ... has changed ... since this executable was linked, file will be ignored HOT 1
- stdin loses unbuffered setting during callbacks HOT 1
- Memory handling for replxx_add_completion() / replxx_add_color_completion() undocumented HOT 1
- Pressing enter right after incremental search doesn't show the accepted line HOT 2
- retrieve last line before EOF HOT 1
- Replxx submitted to Fedora HOT 2
- Prompt is not re-rendered when I press "up" HOT 1
- Multiline text with <tab> leads to crash HOT 4
- How to abort "input" in another thread? HOT 5
- Help: wired behavior of Ctrl-A HOT 2
- segmentation fault on down arrow keypress HOT 5
- How to break loop when user press CTRL+C or CTRL+D or CTRL+Z or ESC ? HOT 2
- Support the switch of beep.
- How to enable multiline HOT 1
- Support custom file descriptors
- Homebrew integration for mac
- Undo
- New warning from gcc 13
- Looks like Marcin Konarski died in November 2021 HOT 5
- Colored user input while displaying hints
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from replxx.