2016-01-01から1年間の記事一覧

言語バーのENがたまに復活する。

id:shive:20160720:1469017510 リストに英語(米国)は存在しないのだけど、もう一回追加して削除してやれば消える。なんなんだ…。

子プロセス起動時に管理者権限での実行を強制する

ShellExecuteExでlpVerb=runasにすれば良いらしい。 #include <windows.h> #include <shellapi.h> #include <cstdio> int main(int, const char**) { SHELLEXECUTEINFO sei = {}; sei.cbSize = sizeof(sei); sei.fMask |= SEE_MASK_WAITFORINPUTIDLE; sei.fMask |= SEE_MASK_FLAG_NO_UI; sei</cstdio></shellapi.h></windows.h>…

WindowsのキーボードタイプにENが現れてしまったときの対処

言語設定で「英語(英国)」を一度追加して削除すると消える。

デコレータで関数に属性を付与

def note(**kw): def applier(func): __notes__ = getattr(func, '__notes__', None) if __notes__ is None: __notes__ = dict() setattr(func, '__notes__', __notes__) __notes__.update(kw) return func return applier @note(foo='this is add') @note(b…

cdefクラスとcpdefの挙動

Cythonでネイティブ実装のPythonクラスを作る。(Cython 0.24 で確認) # hoge.pyx from libc.stdio cimport printf from libcpp.string cimport string cdef class Hoge: cdef string name_ property name: def __get__(self): return self.name_.c_str().d…

.pyxはutf-8-sigにしてはいけない

# -*- coding: utf-8-sig -*- print(b'abc') print('abc') print('abc'.encode('utf-8-sig')) print('abc'.encode('utf-8')) env = Environment() env.Append( CPPPATH=['C:/Python34/include'], LIBPATH=['C:/Python34/libs'], ) env.Command('hoge.cpp', '…

if括弧内で定義した変数の生存期間

c++

ifの括弧内で定義した変数ってelseのスコープでも有効なのね。知らなかった。 // hoge.cpp #include <string.h> #include <stdio.h> int main(int argc, const char** argv) { if(int len = strlen(argv[1])) { printf("then, '%s' len = %d\n", argv[1], len); } else { printf</stdio.h></string.h>…

luajit vs pypy 2016

前回検証した記事がもう4年前。id:shive:20120112:1326376896luajitがちらほら使われるのを見かけるようになったので久しぶりに再検証してみました。https://github.com/shive/try_luajit前に記事を書いた直後にpypyはluajitに抜かれていたので、その後変わ…

Makefileで相対パスからinclude

Makefileから共通ビルド定義をincludeする際にお決まりでincludeするファイルが複数あった場合に、MakefileはC/C++とは違ってinclude先でのパスはinclude元と同じで簡単にパスを取得する方法が見つけられなかったので毎回下記のようにしていた。 # share/com…

cppcheckのバグ

c++

cppcheck-1.72で確認。 // hoge.cpp class Base { }; template<typename T> class Hoge<T[]> final : public Base { }; void func() { int a[2]; a[5] = 0; } $ cppcheck hoge.cpp Checking hoge.cpp... Hogeのfinal消すか継承を消すかT[]をTにするとちゃんと動く $ cppcheck </t[]></typename>…

Win8で削除時に確認ダイアログを表示する

ごみ箱アイコンを右クリックしてプロパティを表示。「削除の確認メッセージを表示する」をチェックしておく。うっかり連打で隣のファイルまで削除されてビビる。

VC2013が無名構造体のメンバに初期値を記述しても初期化してくれない

VisualStudio2013のC++11実装が甘い。 // hoge.cpp #include <stdio.h> struct Hoge { int one = 11; int two = 12; int sun = 13; struct named_t { int one = 21; int two = 22; int sun = 23; } named; struct { int one = 31; int two = 32; int sun = 33; } nona</stdio.h>…