-
Notifications
You must be signed in to change notification settings - Fork 6
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 some miscellaneous MSVC warnings #7
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -136,7 +136,11 @@ void cthreads_thread_exit(void *code) { | |||||||||||
#endif | ||||||||||||
|
||||||||||||
#ifdef _WIN32 | ||||||||||||
#if defined __WATCOMC__ || _MSC_VER || __DMC__ | ||||||||||||
/* NOTE: This gives warnings on MSVC, so I removed this | ||||||||||||
* for the oldest version of it I could test (19.20). */ | ||||||||||||
/* TODO: Test with the other described compilers if this | ||||||||||||
* is _really_ necessary. */ | ||||||||||||
#if defined __WATCOMC__ || _MSC_VER < 1920 || __DMC__ | ||||||||||||
ExitThread((DWORD)code); | ||||||||||||
#else | ||||||||||||
ExitThread((DWORD)(uintptr_t)code); | ||||||||||||
|
@@ -323,6 +327,7 @@ int cthreads_cond_destroy(struct cthreads_cond *cond) { | |||||||||||
#endif | ||||||||||||
|
||||||||||||
#ifdef _WIN32 | ||||||||||||
(void) cond; | ||||||||||||
return 0; | ||||||||||||
Comment on lines
+330
to
331
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
#else | ||||||||||||
return pthread_cond_destroy(&cond->pCond); | ||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -7,6 +7,8 @@ struct cthreads_args { | |||||||||||
}; | ||||||||||||
|
||||||||||||
#ifdef _WIN32 | ||||||||||||
/* MSVC sees strncpy() as insecure. */ | ||||||||||||
#define _CRT_SECURE_NO_WARNINGS | ||||||||||||
Comment on lines
+10
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, is this widely compatible or affects files outside the project? For second case, I believe we can #undef it? Wouldn't be good to apply such for files outside. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm afraid there's no easy way to do this. I think the best course of action is just to remove the define and endur the warning or add an option for the user to disable the define. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion we can should* strncpy for memcpy and just handle NULL terminator ending. With proper testing, it becomes safe anyway. |
||||||||||||
#include <windows.h> | ||||||||||||
#define CTHREADS_SEMAPHORE 1 | ||||||||||||
#else | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, just a suggestion, for me both work.