Skip to content

Instantly share code, notes, and snippets.

View iwadon's full-sized avatar

IWATSUKI Hiroyuki iwadon

View GitHub Profile
@iwadon
iwadon / Makefile
Created October 30, 2012 06:12
CppUnitを真似てファクトリーの登録を分離できるようにしたけど、登録部分をライブラリにしちゃうと当然のごとくリンクされなくて泣ける。どうしたものか。
CXX = g++
CXXFLAGS = -Wall -O2 -g
CPPFLAGS =
AR = ar
LD = g++
LDFLAGS =
LIBS =
RM = rm -f
all: ok ng
#include <stdio.h>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
struct stat st;
if (stat(argv[0], &st) < 0) {
perror("stat()");
return 1;
}
@iwadon
iwadon / gist:2700367
Created May 15, 2012 09:29
sometimes mrblib.o is not merged into libmruby.a
imac:~/src/mruby% rm lib/libmruby.a
imac:~/src/mruby% rm mrblib/mrblib.o
imac:~/src/mruby% make
ar r ../lib/libmruby.a ./array.o ./ascii.o ./cdump.o ./class.o ./codegen.o ./compar.o ./crc.o ./dump.o ./encoding.o ./enum.o ./error.o ./etc.o ./gc.o ./hash.o ./init.o ./init_ext.o ./kernel.o ./load.o ./math.o ./numeric.o ./object.o ./pool.o ./print.o ./proc.o ./range.o ./re.o ./regcomp.o ./regenc.o ./regerror.o ./regexec.o ./regparse.o ./sprintf.o ./st.o ./state.o ./string.o ./struct.o ./symbol.o ./time.o ./transcode.o ./unicode.o ./us_ascii.o ./utf_8.o ./variable.o ./version.o ./vm.o ./y.tab.o
ar: creating archive ../lib/libmruby.a
gcc -Wall -Werror-implicit-function-declaration -g -O3 -MMD -I../src -I../include -c mrblib.c -o mrblib.o
gcc -o ../../bin/mruby -g -O3 ../../src/../tools/mruby/mruby.o ../../lib/libmruby.a -lm
Undefined symbols for architecture x86_64:
"_mrb_init_mrblib", referenced from:
_mrb_init_core in libmruby.a(init.o)
CC = gcc
CC32 = gcc -m32
CC64 = gcc -m64
CFLAGS = -Wall -Wextra -g
CPPFLAGS =
LDFLAGS =
LIBS =
RM = rm -f
TARGETS = sizeof sizeof32 sizeof64
diff --git a/configure.py b/configure.py
index b7d7908..278d42e 100755
--- a/configure.py
+++ b/configure.py
@@ -246,7 +246,7 @@ n.comment('Main executable is library plus main() function.')
objs = cxx('ninja')
ninja = n.build(binary('ninja'), 'link', objs, implicit=ninja_lib,
variables=[('libs', libs)])
-if ninja != 'ninja':
+if ninja != ['ninja']:
diff --git a/configure.py b/configure.py
index 9c9d108..3ceb6fe 100755
--- a/configure.py
+++ b/configure.py
@@ -260,6 +260,8 @@ if options.with_gtest:
gtest_all_incs = '-I%s -I%s' % (path, os.path.join(path, 'include'))
gtest_cflags = '-fvisibility=hidden ' + gtest_all_incs
+ if platform != 'windows':
+ gtest_cflags += " -DGTEST_HAS_RTTI=0"
@iwadon
iwadon / num_va_args.cpp
Created December 20, 2011 03:32
__VA_ARGS__に含まれる引数の数を数えるマクロ。
// Getting the number of variable arguments contained in __VA_ARGS__
// Original idea is: http://groups.google.com/group/comp.std.c/browse_thread/thread/77ee8c8f92e4a3fb/346fc464319b1ee5
#include <cstdio>
#include <iostream>
#define PP_NARG(...) PP_NARG2(0, ##__VA_ARGS__, PP_RSEQ_N)
#define PP_NARG2(...) PP_ARG_N(__VA_ARGS__)
#define PP_ARG_N(__0, __1, __2, __3, __4, __5, __6, __7, __8, __9, \
_10, _11, _12, _13, _14, _15, _16, _17, _18, _19, \
@iwadon
iwadon / gist:1449779
Created December 9, 2011 02:02
twitter - move sidebar to right
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("twitter.com") {
.dashboard {
float: right !important;
}
}
@iwadon
iwadon / sdmkun-1.5.8-20111116.diff
Created November 16, 2011 14:58
「白い弾幕くん」をMac OS X 10.7.2 + SDL 1.3でビルドしたら落ちるのでとりあえず手を加えてみた。
diff --git a/src/mysdl_padinput.h b/src/mysdl_padinput.h
index 630139f..dd52ada 100644
--- a/src/mysdl_padinput.h
+++ b/src/mysdl_padinput.h
@@ -145,7 +145,7 @@ namespace MSDL {
class KeyButtonInput : public ButtonInput {
public:
KeyButtonInput(SDLKey key) : key_(key) {}
- virtual bool getButton() { return SDL_GetKeyState(0)[key_]; }
+ virtual bool getButton() { return SDL_GetKeyboardState(NULL)[SDL_GetScancodeFromKey(key_)]; }
#include <iostream>
int main()
{
try {
throw "hello";
} catch (const char *e) {
std::cout << e << std::endl;
}
return 0;
}