2006年03月10日

C\C++宏大全(转载,原贴地址http://www.cnblogs.com/sevencat/archive/2004/06/10/14872.html)
一、标准预定义宏
The standard predefined macros are specified by the relevant language standards, so they are available with all compilers that implement those standards. Older compilers may not provide all of them. Their names all start with double underscores.

__FILE__
This macro expands to the name of the current input file, in the form of a C string constant. This is the path by which the preprocessor opened the file, not the short name specified in #include or as the input file name argument. For example, "/usr/local/include/myheader.h" is a possible expansion of this macro.

__LINE__
This macro expands to the current input line number, in the form of a decimal integer constant. While we call it a predefined macro, it’s a pretty strange macro, since its "definition" changes with each new line of source code.
__FILE__ and __LINE__ are useful in generating an error message to report an inconsistency detected by the program; the message can state the source line at which the inconsistency was detected. For example,

     fprintf (stderr, "Internal error: "
                      "negative string length "
                      "%d at %s, line %d.",
              length, __FILE__, __LINE__);
    
An #include directive changes the expansions of __FILE__ and __LINE__ to correspond to the included file. At the end of that file, when processing resumes on the input file that contained the #include directive, the expansions of __FILE__ and __LINE__ revert to the values they had before the #include (but __LINE__ is then incremented by one as processing moves to the line after the #include).

A #line directive changes __LINE__, and may change __FILE__ as well. See Line Control.

C99 introduces __func__, and GCC has provided __FUNCTION__ for a long time. Both of these are strings containing the name of the current function (there are slight semantic differences; see the GCC manual). Neither of them is a macro; the preprocessor does not know the name of the current function. They tend to be useful in conjunction with __FILE__ and __LINE__, though.


__DATE__
This macro expands to a string constant that describes the date on which the preprocessor is being run. The string constant contains eleven characters and looks like "Feb 12 1996". If the day of the month is less than 10, it is padded with a space on the left.
If GCC cannot determine the current date, it will emit a warning message (once per compilation) and __DATE__ will expand to "??? ?? ????".


__TIME__
This macro expands to a string constant that describes the time at which the preprocessor is being run. The string constant contains eight characters and looks like "23:59:01".
If GCC cannot determine the current time, it will emit a warning message (once per compilation) and __TIME__ will expand to "??:??:??".


__STDC__
In normal operation, this macro expands to the constant 1, to signify that this compiler conforms to ISO Standard C. If GNU CPP is used with a compiler other than GCC, this is not necessarily true; however, the preprocessor always conforms to the standard unless the -traditional-cpp option is used.
This macro is not defined if the -traditional-cpp option is used.

On some hosts, the system compiler uses a different convention, where __STDC__ is normally 0, but is 1 if the user specifies strict conformance to the C Standard. CPP follows the host convention when processing system header files, but when processing user files __STDC__ is always 1. This has been reported to cause problems; for instance, some versions of Solaris provide X Windows headers that expect __STDC__ to be either undefined or 1. See Invocation.


__STDC_VERSION__
This macro expands to the C Standard’s version number, a long integer constant of the form yyyymmL where yyyy and mm are the year and month of the Standard version. This signifies which version of the C Standard the compiler conforms to. Like __STDC__, this is not necessarily accurate for the entire implementation, unless GNU CPP is being used with GCC.
The value 199409L signifies the 1989 C standard as amended in 1994, which is the current default; the value 199901L signifies the 1999 revision of the C standard. Support for the 1999 revision is not yet complete.

This macro is not defined if the -traditional-cpp option is used, nor when compiling C++ or Objective-C.


__STDC_HOSTED__
This macro is defined, with value 1, if the compiler’s target is a hosted environment. A hosted environment has the complete facilities of the standard C library available.

__cplusplus
This macro is defined when the C++ compiler is in use. You can use __cplusplus to test whether a header is compiled by a C compiler or a C++ compiler. This macro is similar to __STDC_VERSION__, in that it expands to a version number. A fully conforming implementation of the 1998 C++ standard will define this macro to 199711L. The GNU C++ compiler is not yet fully conforming, so it uses 1 instead. We hope to complete our implementation in the near future.

__OBJC__
This macro is defined, with value 1, when the Objective-C compiler is in use. You can use __OBJC__ to test whether a header is compiled by a C compiler or a Objective-C compiler.

__ASSEMBLER__
This macro is defined with value 1 when preprocessing assembly language.

GCC 中普通预定义宏
__GNUC__
__GNUC_MINOR__
__GNUC_PATCHLEVEL__
These macros are defined by all GNU compilers that use the C preprocessor: C, C++, and Objective-C. Their values are the major version, minor version, and patch level of the compiler, as integer constants. For example, GCC 3.2.1 will define __GNUC__ to 3, __GNUC_MINOR__ to 2, and __GNUC_PATCHLEVEL__ to 1. They are defined only when the entire compiler is in use; if you invoke the preprocessor directly, they are not defined.
__GNUC_PATCHLEVEL__ is new to GCC 3.0; it is also present in the widely-used development snapshots leading up to 3.0 (which identify themselves as GCC 2.96 or 2.97, depending on which snapshot you have).

If all you need to know is whether or not your program is being compiled by GCC, you can simply test __GNUC__. If you need to write code which depends on a specific version, you must be more careful. Each time the minor version is increased, the patch level is reset to zero; each time the major version is increased (which happens rarely), the minor version and patch level are reset. If you wish to use the predefined macros directly in the conditional, you will need to write it like this:

          /* Test for GCC > 3.2.0 */
          #if __GNUC__ > 3 || \
              (__GNUC__ == 3 && (__GNUC_MINOR__ > 2 || \
                                 (__GNUC_MINOR__ == 2 && \
                                  __GNUC_PATCHLEVEL__ > 0))
         
Another approach is to use the predefined macros to calculate a single number, then compare that against a threshold:

          #define GCC_VERSION (__GNUC__ * 10000 \
                               + __GNUC_MINOR__ * 100 \
                               + __GNUC_PATCHLEVEL__)
          …
          /* Test for GCC > 3.2.0 */
          #if GCC_VERSION > 30200
         
Many people find this form easier to understand.


__GNUG__
The GNU C++ compiler defines this. Testing it is equivalent to testing (__GNUC__ && __cplusplus).

__STRICT_ANSI__
GCC defines this macro if and only if the -ansi switch, or a -std switch specifying strict conformance to some version of ISO C, was specified when GCC was invoked. It is defined to 1. This macro exists primarily to direct GNU libc’s header files to restrict their definitions to the minimal set found in the 1989 C standard.

__BASE_FILE__
This macro expands to the name of the main input file, in the form of a C string constant. This is the source file that was specified on the command line of the preprocessor or C compiler.

__INCLUDE_LEVEL__
This macro expands to a decimal integer constant that represents the depth of nesting in include files. The value of this macro is incremented on every #include directive and decremented at the end of every included file. It starts out at 0, it’s value within the base file specified on the command line.

__ELF__
This macro is defined if the target uses the ELF object format.

__VERSION__
This macro expands to a string constant which describes the version of the compiler in use. You should not rely on its contents having any particular form, but it can be counted on to contain at least the release number.

__OPTIMIZE__
__OPTIMIZE_SIZE__
__NO_INLINE__
These macros describe the compilation mode. __OPTIMIZE__ is defined in all optimizing compilations. __OPTIMIZE_SIZE__ is defined if the compiler is optimizing for size, not speed. __NO_INLINE__ is defined if no functions will be inlined into their callers (when not optimizing, or when inlining has been specifically disabled by -fno-inline).
These macros cause certain GNU header files to provide optimized definitions, using macros or inline functions, of system library functions. You should not use these macros in any way unless you make sure that programs will execute with the same effect whether or not they are defined. If they are defined, their value is 1.


__CHAR_UNSIGNED__
GCC defines this macro if and only if the data type char is unsigned on the target machine. It exists to cause the standard header file limits.h to work correctly. You should not use this macro yourself; instead, refer to the standard macros defined in limits.h.

__WCHAR_UNSIGNED__
Like __CHAR_UNSIGNED__, this macro is defined if and only if the data type wchar_t is unsigned and the front-end is in C++ mode.

__REGISTER_PREFIX__
This macro expands to a single token (not a string constant) which is the prefix applied to CPU register names in assembly language for this target. You can use it to write assembly that is usable in multiple environments. For example, in the m68k-aout environment it expands to nothing, but in the m68k-coff environment it expands to a single %.

__USER_LABEL_PREFIX__
This macro expands to a single token which is the prefix applied to user labels (symbols visible to C code) in assembly. For example, in the m68k-aout environment it expands to an _, but in the m68k-coff environment it expands to nothing.
This macro will have the correct definition even if -f(no-)underscores is in use, but it will not be correct if target-specific options that adjust this prefix are used (e.g. the OSF/rose -mno-underscores option).


__SIZE_TYPE__
__PTRDIFF_TYPE__
__WCHAR_TYPE__
__WINT_TYPE__
These macros are defined to the correct underlying types for the size_t, ptrdiff_t, wchar_t, and wint_t typedefs, respectively. They exist to make the standard header files stddef.h and wchar.h work correctly. You should not use these macros directly; instead, include the appropriate headers and use the typedefs.

__CHAR_BIT__
Defined to the number of bits used in the representation of the char data type. It exists to make the standard header given numerical limits work correctly. You should not use this macro directly; instead, include the appropriate headers.

__SCHAR_MAX__
__WCHAR_MAX__
__SHRT_MAX__
__INT_MAX__
__LONG_MAX__
__LONG_LONG_MAX__
Defined to the maximum value of the signed char, wchar_t, signed short, signed int, signed long, and signed long long types respectively. They exist to make the standard header given numerical limits work correctly. You should not use these macros directly; instead, include the appropriate headers.

__USING_SJLJ_EXCEPTIONS__
This macro is defined, with value 1, if the compiler uses the old mechanism based on setjmp and longjmp for exception handling.

__NEXT_RUNTIME__
This macro is defined, with value 1, if (and only if) the NeXT runtime (as in -fnext-runtime) is in use for Objective-C. If the GNU runtime is used, this macro is not defined, so that you can use this macro to determine which runtime (NeXT or GNU) is being used.

__LP64__
_LP64
These macros are defined, with value 1, if (and only if) the compilation is for a target where long int and pointer both use 64-bits and int uses 32-bit.

VC的宏定义
VC的标准宏
The compiler recognizes 10 predefined ANSI C macros, and the Microsoft C++ implementation provides several more. These macros take no arguments and cannot be redefined. Their value, except for __LINE__ and __FILE__, must be constant throughout compilation. Some of the predefined macros listed below are defined with multiple values. See the following tables for more information.

ANSI-Compliant Predefined Macros

Macro Description
__DATE__ The compilation date of the current source file. The date is a string literal of the form Mmm dd yyyy. The month name Mmm is the same as for dates generated by the library function asctime declared in TIME.H.
 
__FILE__ The name of the current source file. __FILE__ expands to a string surrounded by double quotation marks.
You can create your own wide string version of __FILE__ as follows:

#include <stdio.h>
#define WIDEN2(x) L ## x
#define WIDEN(x) WIDEN2(x)
#define __WFILE__ WIDEN(__FILE__)
wchar_t *pwsz = __WFILE__;

int main()
{
}
 
__LINE__ The line number in the current source file. The line number is a decimal integer constant. It can be altered with a #line directive. 

__STDC__ Indicates full conformance with the ANSI C standard. Defined as the integer constant 1 only if the /Za compiler option is given and you are not compiling C++ code; otherwise is undefined. 

__TIME__ The most recent compilation time of the current source file. The time is a string literal of the form hh:mm:ss. 

__TIMESTAMP__ The date and time of the last modification of the current source file, expressed as a string literal in the form Ddd Mmm Date hh:mm:ss yyyy, where Ddd is the abbreviated day of the week and Date is an integer from 1 to 31.

微软的VC宏
_ATL_VER Defines the ATL version.
 
_CHAR_UNSIGNED Default char type is unsigned. Defined when /J is specified.
 
__COUNTER__ Expands to an integer starting with 0 and incrementing by 1 every time it is used in a compiland. __COUNTER__ remembers its state when using precompiled headers. If the last __COUNTER__ value was 4 after building a precompiled header (PCH), it will start with 5 on each PCH use.
__COUNTER__ lets you generate unique variable names. You can use token pasting with a prefix to make a unique name. For example:

#include <stdio.h>
#define FUNC2(x,y) x##y
#define FUNC1(x,y) FUNC2(x,y)
#define FUNC(x) FUNC1(x,__COUNTER__)

int FUNC(my_unique_prefix);
int FUNC(my_unique_prefix);

int main() {
   my_unique_prefix0 = 0;
   printf("\n%d",my_unique_prefix0);
   my_unique_prefix0++;
   printf("\n%d",my_unique_prefix0);
}
 
__cplusplus Defined for C++ programs only.
_CPPLIB_VER Defined if you include any of the C++ Standard Library headers; reports which version of the Dinkumware header files are present.

_CPPRTTI Defined for code compiled with /GR (Enable Run-Time Type Information).

_CPPUNWIND Defined for code compiled with /GX (Enable Exception Handling).

_DEBUG Defined when compiling with /LDd, /MDd, /MLd, and /MTd.

_DLL Defined when /MD or /MDd (Multithread DLL) is specified.

__FUNCDNAME__ Valid only within a function and returns the decorated name of the enclosing function (as a string). __FUNCDNAME__ is not expanded if you use the /EP or /P compiler option.

__FUNCSIG__ Valid only within a function and returns the signature of the enclosing function (as a string). __FUNCSIG__ is not expanded if you use the /EP or /P compiler option.

__FUNCTION__ Valid only within a function and returns the undecorated name of the enclosing function (as a string). __FUNCTION__ is not expanded if you use the /EP or /P compiler option.

_M_ALPHA Defined for DEC ALPHA platforms. It is defined as 1 by the ALPHA compiler, and it is not defined if another compiler is used.

_M_IX86 Defined for x86 processors. See values for _M_IX86 for more details.

_M_IA64 Defined for 64-bit processors.

_M_MPPC Defined for Power Macintosh platforms (no longer supported).

_M_MRX000 Defined for MIPS platforms (no longer supported).

_M_PPC Defined for PowerPC platforms (no longer supported).
 
_MANAGED Defined to be 1 when /clr is specified.

_MFC_VER Defines the MFC version. For example, 0×0700 represents MFC version 7.

_MSC_EXTENSIONS This macro is defined when compiling with the /Ze compiler option (the default). Its value, when defined, is 1.

_MSC_VER Defines the major and minor versions of the compiler. For example, 1300 for Microsoft Visual C++ .NET. 1300 represents version 13 and no point release. This represents the fact that there have been a total of 13 releases of the compiler.
If you type cl /? at the command line, you will see the full version for the compiler you are using.
 
__MSVC_RUNTIME_CHECKS Defined when one of the /RTC compiler options is specified.
_MT Defined when /MD or /MDd (Multithreaded DLL) or /MT or /MTd (Multithreaded) is specified. 
_WCHAR_T_DEFINED
and

_NATIVE_WCHAR_T_DEFINED
 Defined when wchar_t is defined. Typically, wchar_t is defined when you use /Zc:wchar_t or when typedef unsigned short wchar_t; is executed in code.
 
_WIN32 Defined for applications for Win32 and Win64. Always defined. 

_WIN64 Defined for applications for Win64.

_Wp64 Defined when specifying /Wp64.

As shown in following table, the compiler generates a value for the preprocessor identifiers that reflect the processor option specified.

values for _M_IX86

Option in Development Environment Command-Line Option Resulting value
Blend /GB _M_IX86 = 600 (Default. Future compilers will emit a different value to reflect the dominant processor.)
Pentium /G5 _M_IX86 = 500
Pentium Pro, Pentium II, and Pentium III /G6 _M_IX86 = 600
80386 /G3 _M_IX86 = 300
80486 /G4 _M_IX86 = 400

__CYGWIN32__ 在使用CYGWIN时定义
__MINGW32__在使用MingW时定义

2005年11月02日

公司介绍:
亿世(ESS)电子科技有限公司是一家美国公司在华独资机构, 其总部位于美国硅谷,是纳斯达克上市高科技公司。公司致力于研发,设计生产和销售高品质多媒体高科技产品,在DVD, Video CD, Camera Phone及数码娱乐产品的相关领域占有主导地位,在国际半导体多媒体产业界享有盛名。
 
ESS公司在北京、深圳、苏州、香港、台湾、韩国等亚太地区设有分公司。同时在这些国家也有着我们庞大的领导世界的客户群。万利达、长虹、新科、创维、TCL、大宇、三星、富士通、松下、索尼、东芝、菲利普、广达、摩托罗拉等都是和ESS公司有着良好合作关系。

北京分公司是ESS公司在亚太地区的研发中心。我们追求公平与公正,尊重人才,创造一个让员工能在为企业做出最大贡献的同时不断发展和完善自己的企业文化环境,正确、规范的管理制度,畅通、开放的沟通渠道,强调员工的主动意识。北京分公司将聘用并开发潜质优秀的人才,把公司建设成为一个大型的研发中心。

我们为员工提供:
*优良的办公环境
*良好的工作设备
*技术培训
*国家规定的各种福利和保险,包括:1)养老保险;2)医疗保险;3)失业保险;4)工伤保险; 5)生育保险; 6)住房公积金;

职位介绍:


Software Engineer :     9410A
- Summary: Design and implement embedded software using C and assembler.
- Assist in the specification and verification of ASICs.
- Specific skills required: C; Assembler; DSP; Matlab; GNU development tools; Modern software engineering practices; Real-time systems.
- Knowledge of MPEG, digital coding/compression, and hardware engineering is preferred.
- 2+ years of professional experience in real-time embedded software using C and assembler.  Self-reliant.  Ability to lead in project development.
- Master of Science or Master of Engineering is preferred.
- Proficiency in spoken and written English.

软件工程师 (9410A)
职位描述:
* 使用C语言和汇编语言开发嵌入式软件;
* 协助硬件设计部门完成ASIC的测试;
技能要求:
* 熟悉C语言,汇编、DSP、MATLAB、GNU开发工具,现代软件工程,实时系统概念;
* 熟悉MPEG及相关数字信号编码压缩过程,有相关硬件开发经验者优先;
* 两年以上实时嵌入式软件开发经验,能够独立承担部分项目。
* 硕士以上学历优先
* 能用英语进行工作交流


ASIC Design Engineer:  9410B
-Summary: Perform logic design and verification in FPGA and ASIC.
- Specific skills required: Coding and simulation in C and Verilog;
- New graduate or 2+ years experience in ASIC/FPGA design;
-Knowledge of MPEGII encoder and decoder is preferred.
- MS or BS in E.E. or C.S.;
- Ability to communicate in English.

ASIC硬件工程师 (9410B)
职位描述:
* 用FPGA和ASIC来完成逻辑设计和验证;
技能要求:
* 能够熟练使用C语言和Verilog
* 应届毕业生或2年以上ASIC或FPGA设计相关经验;
* 熟悉应用MEPEGⅡ进行编码和解码;
* 硕士以上学历优先
* 能用英语进行工作交流

Website: www.esstech.com
请将中、英文简历e-mail 至 zl@esstech.com.cn, 并写明职位代号,请直接粘贴到正文,附件将不予打开。

2005年10月09日
2005年08月11日

http://earth.google.com/

2005年08月09日

http://blog.donews.com/jiji262/archive/2005/08/08/499117.aspx

2005年08月04日

如果互联网的速度问题得到彻底解决,网络肯定会更加精彩。软件业的发展前途一个是行业应用,一个是网络应用。只是到现在感觉网络还没有一个很好的盈利模式,这是最大的问题。如果只是作为信息媒体,我觉得网络远不如传统媒体有优势,一点都不人性话。看个新闻要点半天,等半天,完了出来一小段话和通篇的标题。

今天看了篇关于微软新版操作系统得文章,有这样一段话

不过,微软还是向OEM提供了Longhorn得以良好运行的硬件环境:双核的64位处理器、至少1GB的内存、256MB显存(支持LDDM)和最好能是3000GB以上的硬盘。这个需求尽管没有去年的“谣言”那么恐怖,但谁也无法预言这个配置之于Windows Vista会不会和(300MHz CPU+128MB内存)之于Windows XP那样让人感到痛苦。

新得操作系统已经不再是给所有人设计的了,好象很少有人能达到这个环境得吧,用了这么长时间开发出来的东西实在是令人失望。大多数人恐怕要对新的操作系统望碟兴叹了,必然会失去大量的用户。虽然说中国用户很少给微软捧钱场,但中国捧了人场,这也很重要。微软的IE7好想也很霸道,据说除了MSN外的即时通信软件都不能用了,这段时间我自己也在用VisualStudio2005,感觉也有很多地方很难用,远不如eclipse好用。总的来说,感觉微软已然是日过中天,要落西了。不知道会有哪个星星会升起

2005年07月29日
无论怎么弄就是不行,在网上狂搜一通,终于在 M$BUG反馈站点上找到了解决方案,要把Server Name 改成 .\SQLEXPRESS”或“机器名\SQLEXPRESS就可以了,改了以后一试过来可以了。下面是M$网站上的解释:
http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackid=6da73f4e-ebeb-4dba-965a-41a730b5c965
Resolved as By Design by Microsoft on 2004-07-01 at 10:35:09
Most everyone is used to creating a new database by going to “Add new database“ from the Server Explorer. This approach will still work. (Although you need to use the instance name of SQLExpress. So, type “.\SQLExpress“ for the server name. But, this isn’t the preferred way. The preferred way is to simply copy the database into your project. So, from the project menu, right click and choose “Add new item“ or “Add existing item“. In either case the MDF (and LDF if present) is copied into your project. Then a connection is automatically opened for you in Server Explorer. So, you can directly party on the database structure.
 
http://www.cnblogs.com/9527/archive/2004/10/31/58887.html
2005年07月26日

http://www.techng.com/title.aspx?type=Net&subtype=Framework

3.9. Q 如何在 cygwin 中运行 sshd (SSH Server)?

如下:

  • 设置 Windows 环境变量,添加“CYGWIN = ntsec tty”
  • Config SSHD, running:
        bash$ ssh-host-config -y
根据提示,输入 CYGWIN=ntsec tty
  • Change permissions and ownership on some files:
        bash$ cd /; chmod -R og-w .
        bash$ chmod og+w /tmp
        bash$ touch /var/log/sshd.log
        bash$ chown system:system /var/log/sshd.log /var/empty /etc/ssh_h*
        bash$ chmod 755 /var/empty
  • start the service:
        bash$ cygrunsrv -S sshd