Last active
December 17, 2015 14:59
-
-
Save koturn/5628930 to your computer and use it in GitHub Desktop.
C言語ソースのテンプレート
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if 0 | |
############################################################ | |
### If you execute this source file as a shell-script, ### | |
### you can compile this source file. ### | |
############################################################ | |
gcc -pipe -O3 -s -Wall -Wextra $0 $@ -o ${0%.*} | |
if [ $? -ne 0 ]; then | |
echo '!!!Compile error!!!' | |
fi | |
exit | |
#endif | |
/*! | |
* @brief Temprate C-source file | |
* | |
* This is a template C-source file. | |
* @author koturn 0; | |
* @file template.c | |
* @version 0.1 | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
// Macros for inline-directive under various environmets | |
#ifndef __cplusplus // In language-C | |
# if defined(_MSC_VER) // In Visual C++, | |
# define inline __inline // 'inline' and '__inline__' aren't available | |
# define __inline__ __inline // but '__inline' is. | |
# elif !defined(__GNUC__) && __STDC_VERSION__ < 199901L | |
# define inline // If 'inline' isn't available, remove 'inline' | |
# define __inline // as well as '__inline'. | |
# endif | |
#endif | |
// Macros for restrict-qualifier under various environmets | |
#if _MSC_VER >= 1400 // In Visual C++ (after Visual C++ 2005), | |
# define restrict __restrict // 'restrict' and '__inline__' aren't available | |
# define __restrict__ __restrict // but '__restrict' is. | |
#elif __cplusplus // In language C++ (but not Visual C++), | |
# define restrict __restrict // 'restrict' isn't available but '__restrict' is. | |
#elif !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L | |
# if defined(__GNUC__) // In gcc, | |
# define restrict __restrict // 'restrict' isn't available but '__restrict' is. | |
# else | |
# define restrict // If 'restrict' isn't available, remove 'restrict' | |
# define __restrict // as well as '__restrict' | |
# define __restrict__ // and '__restrict__'. | |
# endif | |
#endif | |
#ifndef __GNUC__ | |
# define __attribute__(attr) // If '__attribute__' isn't available, remove '__attribute__'. | |
#endif | |
/*! | |
* @brief An entry point of this program | |
* @param [in] argc Number of command-line arguments | |
* @param [in] argv Command-line arguments | |
* @return exit-status | |
*/ | |
int main(int argc, char *argv[]) { | |
printf("Hello World!\n"); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment