Skip to content

Commit

Permalink
Adding __decspec for Windows builds
Browse files Browse the repository at this point in the history
  • Loading branch information
greenliquidlight committed Nov 18, 2023
1 parent c7083ae commit 8afe11e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions include/C_Callback.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
#ifndef CALLBACK_DEMO_H
#define CALLBACK_DEMO_H

#ifdef _WIN32
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT
#endif

DLL_EXPORT void YourFunction(); // Example function declaration

#ifdef __cplusplus
extern "C" {
#endif

typedef const void (*CallbackFunction)(int, char*, size_t);

// Simple function that prints a number to the console
void printNumberInDec(int number, char* buffer, size_t bufferSize);
DLL_EXPORT void printNumberInDec(int number, char* buffer, size_t bufferSize);

// Simple function that prints a number to the console in hex
void printNumberInHex(int number, char* buffer, size_t bufferSize);
DLL_EXPORT void printNumberInHex(int number, char* buffer, size_t bufferSize);

// Function that takes a function pointer as an argument and
// set the callback function to the one passed in
void setCallback(CallbackFunction callback);
DLL_EXPORT void setCallback(CallbackFunction callback);

// Run the callback function with the given number
void runCallback(int number, char* buffer, size_t bufferSize);
DLL_EXPORT void runCallback(int number, char* buffer, size_t bufferSize);

#ifdef __cplusplus
}
#endif

#endif // CALLBACK_DEMO_H
#endif // CALLBACK_DEMO_H

0 comments on commit 8afe11e

Please sign in to comment.