shithub: mp3dec

Download patch

ref: 644e0fb7fed34f803b6634f72e5ad8cc20a520f7
parent: 39d6651041e5fb5edfe6a61dc5dd627cdd9b58d8
author: Alibek Omarov <a1ba.omarov@gmail.com>
date: Thu Aug 30 18:54:52 EDT 2018

minimp3: move header include guard before implementation. Add implementation guard.

Test cases:
1.c
 #include "minimp3.h" /* gives definitions */
 ...
 #define MINIMP3_IMPLEMENTATION
 #include "minimp3.h" /* gives implementation */

2.c
 #define MINIMP3_IMPLEMENTATION
 #include "minimp3.h" /* gives defintions and implementation */
 #include "minimp3.h" /* does not gives anything to not confuse compiler */

--- a/minimp3.h
+++ b/minimp3.h
@@ -39,8 +39,10 @@
 }
 #endif /* __cplusplus */
 
-#ifdef MINIMP3_IMPLEMENTATION
-#error
+#endif /* MINIMP3_H */
+#if defined(MINIMP3_IMPLEMENTATION) && !defined(_MINIMP3_IMPLEMENTATION_GUARD)
+#define _MINIMP3_IMPLEMENTATION_GUARD
+
 #include <stdlib.h>
 #include <string.h>
 
@@ -1800,5 +1802,4 @@
     }
 }
 #endif /* MINIMP3_FLOAT_OUTPUT */
-#endif /* MINIMP3_IMPLEMENTATION */
-#endif /* MINIMP3_H */
+#endif /* MINIMP3_IMPLEMENTATION && !_MINIMP3_IMPLEMENTATION_GUARD */