Skip to content

Instantly share code, notes, and snippets.

/*
** CMDLINE.C - Demonstrates accessing command line arguments
*/
#include <stdio.h>
/// "string"[index] 不常见的用法
#define plural_text(n) &"s"[(1 == (n))]
#define plural_text2(n) &"es"[(1 == (n)) << 1]
#include <stdio.h>
struct s1
{
int a;
int b;
double c;
};
struct s2
@zodiac1111
zodiac1111 / color.mk
Created August 22, 2014 05:43
终端颜色
# 参考:
# * http://blog.csdn.net/cherylnatsu/article/details/5878913
# * http://www.termsys.demon.co.uk/vtansi.htm
# 颜色定义
export GREEN=\033[32m
export RED=\033[31m
# 效果定义
export BRIGHT=\033[1m
export Underscore=\033[4m
export REVERSE=\033[7m
@zodiac1111
zodiac1111 / Makefile
Created August 22, 2014 05:42
简单make
# 隐含规则使用的编译器,一般编译时候显式的也使用这个,如下面的$(CC)
CC=gcc
#隐含规则使用的预处理选项
CPPFLAGS= -I..
#隐含规则使用的编译(complie)器选项
CFLAGS=-Wall -g
#连接器选项,不是隐含的,需要显式指出
CC=gcc
PREFIX=$PWD
SRC=opt.c
EXE=a.out
.PHONY: all install clean distclean dist
all:
$(CC) $(SRC) -o $(EXE)
install:
@zodiac1111
zodiac1111 / Makefile
Created August 22, 2014 05:41
程序国际化例子
# 参考来源 :http://www.jiangmiao.org/blog/1285.html
#大致流程
# po目录
PO=po
LANGDIR=languages
# 翻译的语言的代码
LG=zh_CN
######## 一. 简单整合命令 #########
all:build
.PHONY:all staticlib main clean
all: staticlib main
staticlib:
gcc -c staticlib.c -o staticlib.o
ar -r staticlib.a staticlib.o
main:
gcc main.c staticlib.a
@zodiac1111
zodiac1111 / Makefile
Last active September 19, 2022 00:04
串口操作
CC=gcc
all:
$(CC) uart.c -o uart_app -Wall
@zodiac1111
zodiac1111 / main.c
Last active August 29, 2015 14:05 — forked from brendanashworth/main.c
Basic example multithreading in C
#import <stdio.h>
#import <pthread.h>
void *threadFunction(void *arg) {
// To be executed when called...
}
int main(void) {
pthread_t *thread;
@zodiac1111
zodiac1111 / jsonio.js
Created August 22, 2014 05:28 — forked from thekarel/jsonio.js
JSON I/O
// From JSON
var jsObject = JSON.parse(jsonString);
// To JSON
var jsonString = JSON.stringify(foo);