#define Max_key_length 128 #define Form inttypedefstruct_Data{charkey[Max_key_length];/*用途によって変更*/Formval;}Data;typedefstruct_Map{Data*hash_table;unsignedsize;unsignedamount;}Map;intmake_hash(Map*,char*);voidinit_map(Map*,unsigned);voidrefresh(Map*,unsigned);intput(Map*,char*,v...
#define _MSG4(lv,msg,...) fprintf(stderr,_LOG(msg),lv,_FMT,__VA_ARGS__)/* 使用例 */inttest_function(void){FILE*fp;fp=fopen("file_never_exist","r");if(fp==NULL){ERRORMSG("%s\n",strerror(errno));return-1;}fclose(fp);return0;}intmain(intargc,char**argv){INFOMSG("test...
#include<stdio.h>#include<stdlib.h>#defineSIZE (1024*1024*100)intmain(void){int*ptr =NULL;inti; ptr = (int*)malloc(sizeof(int) * SIZE);if(ptr ==NULL) {return-1; }free(ptr);for(i =0; i < SIZE; i ++) { ptr[i] = i; }return0; } ...
#define_GNU_SOURCE#include<sched.h>#include<stdio.h>#include<stdlib.h>#include<sys/wait.h>#include<unistd.h>#defineerrExit(msg) \ do { \ perror(msg); \ exit(EXIT_FAILURE); \ } while (0)intmain(intargc,char*argv[]){cpu_set_t set;intparentCPU,childCPU,wstatus;longnloops;if(arg...
#define TPTRAN 0x00000010 /* トランザクション・モードでの送信 */ #define TPNOTIME 0x00000020 /* タイムアウトなし */ #define TPABSOLUTE 0x00000040 /* 絶対的な優先順位の指定 */ #define TPGETANY 0x00000080 /* 有効応答の取り込み */ #define TPNOCHANGE 0x00000100 /* 受信バ...
どちらの関数もコピー先の文字列へのポインタを返し、これによりチェーニング呼び出しが可能になります。 #include<stdio.h>#include<stdlib.h>#include<string.h>#ifndefMAX#defineMAX 100#endifintmain(){constchar*str1="hello there 1";constchar*str2="hello there 2";charbuffer[MAX];strcat(...
この構造体は、tpdequeue()でも使用され、一部のフィールドは、アプリケーションがこの関数を呼び出すまで使用されません。コードリスト3-1は、この構造体全体を示しています。 リスト3-1 tpqctl_t構造体 #define TMQNAMELEN 127 #define TMMSGIDLEN 32 #define TMCORRIDLEN 32struct tpqctl_...
マクロで with string jump table #define BITS(c) __bits__ + 9 * (255u & c)staticconstchar__bits__[]="00000000\0""00000001\0""00000010\0""00000011\0""00000100\0""00000101\0""00000110\0""00000111\0""00001000\0""00001001\0""00001010\0""00001011\0""00001100\0""00001101\0""0000...
MinGWとVisual Studioとでコードを共通化する場合は、__MINGW32__または__MINGW64__がdefineされているかで切り分けをします。 Qt (c++)でWindowsとLinuxを認識するマクロ - スタック・オーバーフロー UNIX向けソフトウェアをMinGWに移植する際のテクニック - なんとな~くしあわせ?の日記 Pre...
次に、strdupa関数呼び出しで文字列を複製し、strsepで渡されたポインタを変更します。strdupaはスタック上にダイナミックメモリを確保するので、呼び出し元はそこから返されたポインタを解放してはならません。 #define_GNU_SOURCE#include<stdio.h>#include<stdlib.h>#include<string.h>intmain(...