From aae60e1e440ebd38573195ae81226f01d30f272b Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 15 Aug 2021 13:02:53 +0200 Subject: [PATCH] REVIEWED: `extern "C"` definition position for consistency Note that `extern "C"` calling convention only affects objects that need to be seen by the linker, in our case only functions... but it would also be required by global variables exposed, if any. --- src/camera.h | 9 +++++---- src/raylib.h | 18 ++++++++---------- src/rlgl.h | 8 +++++--- src/utils.h | 8 +++++--- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/camera.h b/src/camera.h index 35eda831..08448089 100644 --- a/src/camera.h +++ b/src/camera.h @@ -94,10 +94,6 @@ } CameraProjection; #endif -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif - //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -106,6 +102,11 @@ extern "C" { // Prevents name mangling of functions //---------------------------------------------------------------------------------- // Module Functions Declaration //---------------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { // Prevents name mangling of functions +#endif + #if defined(CAMERA_STANDALONE) void SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available) void UpdateCamera(Camera *camera); // Update camera position for selected mode diff --git a/src/raylib.h b/src/raylib.h index 7f872813..4c05aeed 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -83,17 +83,16 @@ #define RAYLIB_VERSION "3.8-dev" +#ifndef RLAPI + #define RLAPI // We are building or using rlgl as a static library (or Linux shared library) +#endif + #if defined(_WIN32) - // Microsoft attibutes to tell compiler that symbols are imported/exported from a .dll #if defined(BUILD_LIBTYPE_SHARED) #define RLAPI __declspec(dllexport) // We are building raylib as a Win32 shared library (.dll) #elif defined(USE_LIBTYPE_SHARED) #define RLAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll) - #else - #define RLAPI // We are building or using raylib as a static library #endif -#else - #define RLAPI // We are building or using raylib as a static library (or Linux shared library) #endif //---------------------------------------------------------------------------------- @@ -894,11 +893,6 @@ typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, unsigned typedef char *(*LoadFileTextCallback)(const char *fileName); // FileIO: Load text data typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileIO: Save text data - -#if defined(__cplusplus) -extern "C" { // Prevents name mangling of functions -#endif - //------------------------------------------------------------------------------------ // Global Variables Definition //------------------------------------------------------------------------------------ @@ -908,6 +902,10 @@ extern "C" { // Prevents name mangling of functions // Window and Graphics Device Functions (Module: core) //------------------------------------------------------------------------------------ +#if defined(__cplusplus) +extern "C" { // Prevents name mangling of functions +#endif + // Window-related functions RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed diff --git a/src/rlgl.h b/src/rlgl.h index 6d18638d..3c995c79 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -457,13 +457,14 @@ typedef enum { RL_SHADER_ATTRIB_VEC4 // Shader attribute type: vec4 (4 float) } rlShaderAttributeDataType; +//------------------------------------------------------------------------------------ +// Functions Declaration - Matrix operations +//------------------------------------------------------------------------------------ + #if defined(__cplusplus) extern "C" { // Prevents name mangling of functions #endif -//------------------------------------------------------------------------------------ -// Functions Declaration - Matrix operations -//------------------------------------------------------------------------------------ RLAPI void rlMatrixMode(int mode); // Choose the current matrix to be transformed RLAPI void rlPushMatrix(void); // Push the current matrix to stack RLAPI void rlPopMatrix(void); // Pop lattest inserted matrix from stack @@ -642,6 +643,7 @@ RLAPI void rlSetMatrixViewOffsetStereo(Matrix right, Matrix left); // Set e // Quick and dirty cube/quad buffers load->draw->unload RLAPI void rlLoadDrawCube(void); // Load and draw a cube RLAPI void rlLoadDrawQuad(void); // Load and draw a quad + #if defined(__cplusplus) } #endif diff --git a/src/utils.h b/src/utils.h index 50f70420..c9b33181 100644 --- a/src/utils.h +++ b/src/utils.h @@ -55,9 +55,7 @@ //---------------------------------------------------------------------------------- // Types and Structures Definition //---------------------------------------------------------------------------------- -#ifdef __cplusplus -extern "C" { // Prevents name mangling of functions -#endif +//... //---------------------------------------------------------------------------------- // Global Variables Definition @@ -67,6 +65,10 @@ extern "C" { // Prevents name mangling of functions //---------------------------------------------------------------------------------- // Module Functions Declaration //---------------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { // Prevents name mangling of functions +#endif + #if defined(PLATFORM_ANDROID) void InitAssetManager(AAssetManager *manager, const char *dataPath); // Initialize asset manager from android app FILE *android_fopen(const char *fileName, const char *mode); // Replacement for fopen() -> Read-only!