York Jong's Library tagged → View Popular
石頭閒語:擁抱變化,從函數指標到函數個體 - 樂多日誌
有一天,"偉大的"架構設計師交代甲和乙兩位程序員共同負責撰寫一個小程式。這個程式配置了兩個陣列,一個是傳統的整數陣列,一個是整數vector。這個程式要將這兩個陣列的內容傾印出來。
Doxygen Preprocessing
Source files that are used as input to doxygen can be parsed by doxygen's built-in C-preprocessor.
编程的那些事儿
我抓住了哪些转瞬就在我脑中消失的思想,,因为它们远比一切成书的东西都让我感到它的珍贵!而更玄的是,他们竟然真的能够被文字描述出来!!这整本书就是小说式的教学。它力求呈现出一个精致化了的术语集。以使初学者能真正理解至关重要的那些概念
一个有趣的关于C宏的题目及巧解
定義一個C宏,實現插入0~255個NOP指令
-
//宏定义方法:
#define __NOP1__ asm("nop");
#define __NOP2__ __NOP1__ __NOP1__
#define __NOP4__ __NOP2__ __NOP2__
#define __NOP8__ __NOP4__ __NOP4__
#define __NOP16__ __NOP8__ __NOP8__
#define __NOP32__ __NOP16__ __NOP16__
#define __NOP64__ __NOP32__ __NOP32__
#define __NOP128__ __NOP64__ __NOP64__
#define __NOPX__(a) \
if ((a)&(0x01)) {__NOP1__} \
if ((a)&(0x02)) {__NOP2__} \
if ((a)&(0x04)) {__NOP4__} \
if ((a)&(0x08)) {__NOP8__} \
if ((a)&(0x10)) {__NOP16__} \
if ((a)&(0x20)) {__NOP32__} \
if ((a)&(0x40)) {__NOP64__} \
if ((a)&(0x80)) {__NOP128__}
//宏引用方法(举例):
__NOPX__(13)
//编译结果:
138: __NOPX__(13)
051D 0000 NOP
051E 0000 NOP
051F 0000 NOP
0520 0000 NOP
0521 0000 NOP
0522 0000 NOP
0523 0000 NOP
0524 0000 NOP
0525 0000 NOP
0526 0000 NOP
0527 0000 NOP
0528 0000 NOP
0529 0000 NOP
OO Programing in C (3)
Linux內核中用C提供了一套非常巧妙的方法操作鏈表,位於.../linux/include/linux/list.h,只用一些宏和inline函數來實現雙向鏈表。摘抄一部分出來
-
struct list_head {
struct list_head *next, *prev;
}; -
/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.
* @type: the type of the struct this is embedded in.
* @member: the name of the list_struct within the struct.
*/
#define list_entry(ptr, type, member) \
container_of(ptr, type, member) - 6 more annotations...
以 C 語言實做 Functional Language 的 Currying
「把接受多個參數的函數變換成接受一個單一參數(最初函數的第一個參數)的函數,並且返回接受餘下的參數而且返回結果的新函數的技術。
Open source Clustering software
The open source clustering software available here implement the most commonly used clustering methods for gene expression data analysis. The clustering methods can be used in several ways. Cluster 3.0 provides a Graphical User Interface to access to the clustering routines. It is available for Windows, Mac OS X, and Linux/Unix. Python users can access the clustering routines by using Pycluster, which is an extension module to Python. People that want to make use of the clustering algorithms in their own C, C++, or Fortran programs can download the source code of the C Clustering Library.
江湖一點訣
假如你用 355/113 這個法子,前輩還是會笑你分子 355 超過 8 位元能表示的範圍,
113 也不是 2 的冪次,用在 8051 這種 8 位元系統上還是不適合,那 201/64 這個完美
的結果是如何找出來的?
Rob Pike: Notes on Programming in C
What follows is a set of short essays that collectively encourage a philosophy of clarity in programming rather than giving hard rules.
-
Length is not a virtue in a name;
clarity of expression is. -
When the variable names are
huge, it's harder to see what's going on. - 13 more annotations...
Programmers Lounge - Graphics Basics: August 2007
All the basic graphics programs goes here
Unicode for Programmers - Windows
This article focuses exclusively on system-level Windows programming in C and C++. Other languages designed for Windows, such as Visual Basic, deal with Unicode in their own idiosyncratic ways. Starting with .NET, all of these languages (including VB.NET and C#) now use UTF-16 Unicode strings.
-
On Windows, as in Java, using Unicode means using UTF-16 as the
general-purpose encoding for manipulating text in memory and passing
strings to APIs. -
On Windows/x86 platforms,
wchar_tis a
16-bit type, and it is used exclusively for Unicode. - 5 more annotations...
C语言的宏定义--匠人的百宝箱
-
3,得到指定地址上的一个字节或字
#define MEM_B( x ) ( *( (byte *) (x) ) )
#define MEM_W( x ) ( *( (word *) (x) ) )
-
6,得到一个结构体中field所占用的字节数
#define FSIZ( type, field ) sizeof( ((type *) 0)->field )
> - 5 more annotations...
Efficient C Code for Eight-Bit MCUs
-
• Embedded systems interact with hardware. ANSI C provides
extremely crude tools for addressing registers at fixed memory locations.
Consequently, most compiler vendors offer language extensions to overcome
these limitations
• All nontrivial
systems use interrupts. ANSI C doesn’t have a
standard way of coding interrupt service routines
• ANSI C has various type promotion rules that are absolute
performance killers to an eight-bit machine. Unless your system has
abundant CPU cycles, you will quickly learn to defeat the ANSI promotion
rules
• Many microcontrollers have multiple memory spaces, which have
to be specified in order to correctly address the desired variable. Thus,
variable declarations tend to be considerably more
complex than on the
typical PC application
• Many microcontrollers have no hardware support for a C stack.
Consequently, some compiler vendors dispense with a stack-based
architecture, in the process eliminating several key features of C -
• Use the smallest possible type to get the job done
• Use an unsigned type if possible - 14 more annotations...
一個常用於設定Register的macro - GaryLee
-
- REG_ADDR
- REG_VALUE
在為數不少硬體中,要存取其內部的register可能需要透過I/O port的方式進行。舉例來說,如果有兩個I/O port分別為
- REG_ADDR
-
#define REG(_reg_) *(REG_ADDR = (_reg_), ®_VALUE)
'Optimal' C Constructs for 8051 Microprocessors
-
On 8-bit systems, however, a subtle change in coding style can affect performance significantly.
-
This result comes about because the 8051 has a Decrement and Jump Not Zero (DJNZ) instruction that is designed for efficient looping. However, it requires the loop variable to count down-hence the for-loop that counts down gives the best performance.
- 8 more annotations...
Selected Tags
Related Tags
Sponsored Links
Top Contributors
Groups interested in C
Diigo is about better ways to research, share and collaborate on information. Learn more »
Join Diigo

