Skip to content

Commit

Permalink
iox-eclipse-iceoryx#2301 Fix Windows 32-bit C example
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed Jan 7, 2025
1 parent 96a50e4 commit 6466721
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ void cyclicRun(iox_user_trigger_t trigger)
fflush(stdout);
}

void* cyclicTriggerCallback(void* dontCare)
#if defined(_WIN32)
DWORD WINAPI cyclicTriggerCallback(LPVOID param)
#else
void* cyclicTriggerCallback(void*)
#endif
{
// Ignore unused variable warning
(void)dontCare;
int countdownToTrigger = 100;
while (keepRunning)
{
Expand All @@ -78,13 +80,13 @@ void* cyclicTriggerCallback(void* dontCare)
return NULL;
}

bool createThread(pthread_t* threadHandle, void* (*callback)(void*))
bool createThread(pthread_t* threadHandle)
{
#if defined(_WIN32)
threadHandle = CreateThread(NULL, 8192, callback, NULL, 0, NULL);
threadHandle = CreateThread(NULL, 8192, cyclicTriggerCallback, NULL, 0, NULL);
return threadHandle != NULL;
#else
return pthread_create(threadHandle, NULL, callback, NULL) == 0;
return pthread_create(threadHandle, NULL, cyclicTriggerCallback, NULL) == 0;
#endif
}

Expand Down Expand Up @@ -121,7 +123,7 @@ int main(void)
// start a thread which triggers cyclicTrigger every second
//! [cyclic trigger thread]
pthread_t cyclicTriggerThread;
if (!createThread(&cyclicTriggerThread, cyclicTriggerCallback))
if (!createThread(&cyclicTriggerThread))
{
printf("failed to create thread\n");
return -1;
Expand Down

0 comments on commit 6466721

Please sign in to comment.