- 浏览: 208124 次
- 性别:
- 来自: 北京
最新评论
-
fuliang:
more cleanner than before
Big Integer Arithmetic -
yaojingguo:
Hi, Liang LiangThanks for the i ...
Redirect and restore stdout in C -
fuliang:
使用gcc编译.cpp,可以使用-lstdc++选项,这样gc ...
Redirect and restore stdout in C
文章列表
#include <iostream>
using namespace std;
class Throwable {
public:
void print() {
cout << "Throwable XXX" << endl;
}
};
int main(int argc, const char *argv[]) {
try {
throw Throwable();
} catch (Throwable t) {
t.print();
...
================
non-inline functions
================
For non-inline functions, if the prototype does not change, often the files that use the function need not be recompiled.
lib.cpp
#include <stdio.h>
void show(int i) {
printf("show %d using style 1\n", i);
}
...
main.c
extern void func();
int main(int argc, const char *argv[]) {
func();
return 0;
}
lib.c
#include <stdio.h>
void func(int i) {
printf("param: %d\n", i);
}
$ gcc main.c lib.c
$ ./a.out
param: 134513712
$ g++ main.c lib.c
/tmp/ccxkNQ9h ...
main.c
#include <stdio.h>
struct S {
short int x;
int y;
double z;
};
void zero_y(struct S *s_p);
int main(int argc, const char *argv[]) {
struct S s1;
s1.x = 1;
s1.y = 2;
s1.z = 1.2;
zero_y(&s1);
printf("S.y: %u\n", s1.y);
return 0; ...
Copy the font files to a directory that is visible to the x-server's
Font Path. You may check the font path of the running server by
typing the command:
xset q
On my FreeBSD machine I chose /usr/X11R6/lib/X11/fonts/misc/ to hold
these new fonts. Next, you need to update the index file ...
Start at the variable name (or innermost construct if no identifier is present. Look right without jumping over a right parenthesis; say what you see. Look left again without jumping over a parenthesis; say what you see. Jump out a level of parentheses if any. Look right; say what you see. Look ...
Code demostrating "Distinguishing C++ Declarations from Expressions" in The Definitive ANTLR Reference.
#include <stdio.h>
typedef int I;
char x = 'a';
void foo() {
I(x);
x = 10;
printf("x = %d in foo\n", x);
}
struct _node {
int m;
};
typedef ...
For how to use it, refer to http://openjdk.java.net/projects/compiler-grammar/antlrworks/.
It seems that Java.g can only be accessed by using some internet proxy. So I attached it.
OpenJDK will use ANTLR for javac. Terence Parr is amazing.
Make sample code in http://www.ibm.com/developerworks/java/library/j-jtp11137.html and http://www.ibm.com/developerworks/java/library/j-jtp03048.html runnable.
public class SelectMaxProblem {
private final int[] numbers;
private final int start;
private final int end;
public Sele ...
public class TTT {
public static void main (String [] args) {
X x = new X();
new Thread(new Waiter(x)).start();
new Thread(new Waiter(x)).start();
new Thread(new Notifier(x)).start();
}
}
class X {
synchronized void w() throws InterruptedException {
before(); ...
class A {
public static void one() {
System.out.println("begin one");
B.two();
System.out.println("end one");
}
}
class B {
public static void two() {
System.out.println("begin two");
Throwable t = new Throwable();
t.prin ...
public class Stop {
public static void main (String [] args) {
Slave s = new Slave();
s.start();
s.stop();
}
}
class Slave extends Thread {
@Override
public void run() {
try {
System.out.println("one");
Thread.sleep(2000);
...
public class Join {
public static void main (String [] args) throws Exception {
Controller c = new Controller();
c.start();
Thread.sleep(100);
c.interrupt();
}
}
class Job extends Thread {
@Override
public void run() {
try {
Thread.sleep(2000);
...
#include <stdio.h>
int main(void)
{
int x = 10, y = 1;
asm ("movl %1, %%eax;"
"movl %%eax, %0;"
:"=&r"(y) /* y is output operand, note the
& constraint modifier. */
:"r"(x) /* x is input operand */
:"%e ...