Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix char/wchar/tchar inconsistencies in PythonService.cpp #1373

Closed

Conversation

joankaradimov
Copy link
Contributor

While trying to compile the code with gcc I got a bunch of errors. I fix them in this PR. Most of the fixes make sense, but there is one dodgy part that needs to be reviewed:

#ifdef UNICODE
MultiByteToWideChar(CP_ACP, 0, szmbTraceback, tb_len, szTraceback, tb_len);
#else
strncpy(szTraceback, szmbTraceback, tb_len);
#endif

@mhammond
Copy link
Owner

Fixing inconsistencies sounds great, but if possible, I'd rather consistently use WCHAR - there's no reason to have this building with narrow characters. setup.py tries to force unicode, but does this cause an issue with gcc?

@joankaradimov
Copy link
Contributor Author

setup.py tries to force unicode, but does this cause an issue with gcc?

No, gcc/mingw handles UNICODE/wchar_t just fine.

Fixing inconsistencies sounds great, but if possible, I'd rather consistently use WCHAR

I could do that too. The problem is this function:

static BOOL ReportError(DWORD, LPCTSTR *inserts = NULL, WORD errorType = EVENTLOG_ERROR_TYPE);

It uses LPCTSTR for the inserts argument and not LPCWSTR. And the function is used quite a bit. I just went with what involves less changes. But I could make the inserts argument be wide string and change all of its usages.

@mhammond
Copy link
Owner

It uses LPCTSTR for the inserts argument and not LPCWSTR

But aren't they always identical in this case because this is never built without UNICODE defined?

@joankaradimov
Copy link
Contributor Author

I didn't say it's an error, I said it's an inconsistency :)

Copy link
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, I'd really prefer this consistently use WCHAR instead of TCHAR.

@joankaradimov
Copy link
Contributor Author

joankaradimov commented Sep 18, 2019

I'll try to figure out if I can improve the current state of things and force push new commits. If I can't find a way I'll just close the PR.

@joankaradimov
Copy link
Contributor Author

I'm closing this. Nothing I do is an improvement on either the current code or the code in the PR.

@joankaradimov joankaradimov deleted the char-type-inconsistencies branch December 24, 2019 12:36
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.

2 participants