1 /* 2 * Copyright (c) 2011-2019 EditorConfig Team 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef GLOBAL_H__ 28 #define GLOBAL_H__ 29 30 #include "config.h" 31 32 #include <stddef.h> 33 #include <stdio.h> 34 #include <stdlib.h> 35 #include <string.h> 36 37 /* 38 * Microsoft Visual C++ and some other Windows C Compilers requires exported 39 * functions in shared library to be defined with __declspec(dllexport) 40 * declarator. Also, gcc >= 4 supports hiding symbols that do not need to be 41 * exported. 42 */ 43 #ifdef editorconfig_shared_EXPORTS /* We are building shared lib if defined */ 44 # ifdef WIN32 45 # ifdef __GNUC__ 46 # define EDITORCONFIG_EXPORT __attribute__ ((dllexport)) 47 # else /* __GNUC__ */ 48 # define EDITORCONFIG_EXPORT __declspec(dllexport) 49 # endif /* __GNUC__ */ 50 # else /* WIN32 */ 51 # if defined(__GNUC__) && __GNUC__ >= 4 52 # define EDITORCONFIG_EXPORT __attribute__ ((visibility ("default"))) 53 # define EDITORCONFIG_LOCAL __attribute__ ((visibility ("hidden"))) 54 # endif /* __GNUC__ && __GNUC >= 4 */ 55 # endif /* WIN32 */ 56 #endif /* editorconfig_shared_EXPORTS */ 57 58 /* 59 * For other cases, just define EDITORCONFIG_EXPORT and EDITORCONFIG_LOCAL, to 60 * make compilation successful 61 */ 62 #ifndef EDITORCONFIG_EXPORT 63 # define EDITORCONFIG_EXPORT 64 #endif 65 #ifndef EDITORCONFIG_LOCAL 66 # define EDITORCONFIG_LOCAL 67 #endif 68 69 /* a macro to set editorconfig_version struct */ 70 #define SET_EDITORCONFIG_VERSION(editorconfig_ver, maj, min, submin) \ 71 do { \ 72 (editorconfig_ver)->major = (maj); \ 73 (editorconfig_ver)->minor = (min); \ 74 (editorconfig_ver)->patch = (submin); \ 75 } while(0) 76 77 #endif /* !GLOBAL_H__ */ 78 79