Entries from 2013-01-01 to 1 month

Call Python functions from C++ on Ubuntu 12.04

Code /home/shinya/py_example/mymain.py import sys def main(args): sys.stdout.write('Hello, world!\n'); if args: sys.stdout.write('{0}\n'.format(args)) /home/shinya/py_example/main.cc #include <Python.h> #include <cassert> #include <iostream> int main(int argc, char** </iostream></cassert></python.h>…

Call Java functions from C++ by using Java Native Interface (JNI) on Ubuntu 12.04

Code /home/shinya/jni_example/Main.java public class Main { public static void main(String[] args) { System.out.println("Hello, world!"); if (1 <= args.length) { System.out.println(args[0]); } } } /home/shinya/jni_example/main.cc #include <jni.h></jni.h>…

Tokenize c, c++ and objective-c files with clang

// tokenizer.cc // Copyright (c) 2013 Shinya // The MIT License (MIT) http://opensource.org/licenses/mit-license.php #include <iostream> #include <clang-c/Index.h> void DisplayTokens(const CXTranslationUnit& tu) { CXCursor cursor = clang_getTranslationUnitCursor(tu)</clang-c/index.h></iostream>…

Find tabs with grep

$ grep -r $'\t' * References 逆引きUNIXコマンド/grepでタブを検索する方法 - Linuxと過ごす (Japanese)