Skip to content

Instantly share code, notes, and snippets.

@msakai
Last active Aug 29, 2015
Embed
What would you like to do?
fix warnings of LCM 3.0
  • lcm_io.cprintfで変数zlong long int なので %d ではなく %lld で受ける必要がある
  • 同個所で引数の数よりも余計に %d があるのを削除
  • lib_e.cexitを使うためにstdlib.hをinclude
  • lib_e.cprintf のフォーマット文字列で、引数が size_t なので %d ではなく %zd で受ける必要がある
diff -up lcm30.orig/lcm_io.c lcm30/lcm_io.c
--- lcm30.orig/lcm_io.c 2005-05-30 06:55:12.000000000 +0900
+++ lcm30/lcm_io.c 2015-01-04 17:12:27.609469346 +0900
@@ -42,7 +42,7 @@ int LCM_BM_load ( char *filename ){
}
LCM_BM_MAXITEM = MAX(zz,12);
if ( LCM_print_flag &2 )
- printf ("Reduced %d, #items in BitMap= %d %d\n", z*2, LCM_BM_MAXITEM);
+ printf ("Reduced %lld, #items in BitMap= %d\n", z*2, LCM_BM_MAXITEM);
for ( bnum=item=0 ; item<LCM_Eend ; item++ ){
if ( Eq[FASTO_perm[item]] < LCM_th ) Eq[FASTO_perm[item]] = -1;
/* if item FASTO_perm[item] is infrequent, set Eq[FASTO_perm[item]]=-1 */
diff -up lcm30.orig/lib_e.c lcm30/lib_e.c
--- lcm30.orig/lib_e.c 2007-06-13 14:18:56.000000000 +0900
+++ lcm30/lib_e.c 2015-01-04 17:09:23.853541194 +0900
@@ -5,6 +5,7 @@
#include<stdio.h>
#include<string.h>
+#include<stdlib.h>
#define QUEUE_INT int
@@ -12,8 +13,8 @@
#define MAX(a,b) ((a)>(b)?a:b)
#define MIN(a,b) ((a)<(b)?a:b)
-#define malloc2(f,a,b,c) if(!(f=(a *)malloc(sizeof(a)*(b)))){printf("memory error %s (%d byte)\n",c,sizeof(a)*(b));exit(1);}
-#define realloc2(f,a,b,c) if(!(f=(a *)realloc(f,sizeof(a)*(b)))){printf("memory error, %s (%d byte)\n",c,sizeof(a)*(b));exit(1);}
+#define malloc2(f,a,b,c) if(!(f=(a *)malloc(sizeof(a)*(b)))){printf("memory error %s (%zd byte)\n",c,sizeof(a)*(b));exit(1);}
+#define realloc2(f,a,b,c) if(!(f=(a *)realloc(f,sizeof(a)*(b)))){printf("memory error, %s (%zd byte)\n",c,sizeof(a)*(b));exit(1);}
#define free2(a) {if(a){free(a);(a)=NULL;}a=0;}
#define fopen2r(f,a,c) if(!(f=fopen(a,"r+"))){printf("%s:file open error %s\n",c,a);exit(1);}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment