dl8dtl - Nov 26, 2006 - 08:38 PM Post subject: RE: Binary constants in IAR C ?> Binary notation was added in C99 if I remember correctly.
No, it's been rejected by the committee.
In the C99 rationale, you can find under 6.4.4.1 Integer constants:
``A proposal to add binary constants was rejected due to lack of precedent and insufficient utility.''
So please tell your (national) standards body there *is* sufficient utility for it. As for the first part, I'm trying to get the 0b patch officially as an extension into GCC. Once that happened, there will be at least one very prominent C implementation that sets a precedent case. ;-) All those microcontroller implementations are probably nothing the ISO C standardization body might be aware of, but for sure, GCC is.
> IAR is not fully up to C99 yet,
It's about the most complete C99 implementation I've seen.
학교에서 컴파일러 배운지도 오래되서 기억도 가물가물하는데,
아무튼 컴파일이라는 과정은 생각보다 여러단계를 거친다.
1단계는 #define 이나 #include 등의 매크로프로세서를 처리하는 과정
2단계는 매크로 처리된 C언어를 컴파일하는 과정(문법 확인)
3단계를 컴파일 된 결과물인 어셈블리 코드를 오브젝트로 변환하는 과정
4단계는 오브젝트들을 서로 묶어주는 과정
5단계는 이런 묶인 녀석들을 메모리에서 돌아가도록 하는 로더라는 녀석을 붙이는 과정을 거친다.
이렇게 단계가 나누어져 있다 보니,
gcc에서는 단계별 결과를 추출해 낼수 있다.
예를들어, 매크로가 복잡해서 소스 추적이 힘들경우
매크로 프로세서를 거친 결과만을 뽑아내고 싶다고 한다면
gcc -E 옵션을 사용하면 매크로가 제외된(처리된) 결과가 stdout으로 나온다. gcc -E 소스파일 > 저장할 파일
이런식으로 한단계만 거쳐 디버깅에 사용할 수도 있다.
추가적으로, Makefile 에서
CPP 는 C++이 아니라 C PreProcessor = 매크로 프로세서 이고
CC 는 C Compiler
AS 는 Assembler
LD 는 Loader (링커) 를 의미한다.
-l library
Search the library named library when linking. (The second alternative with the library as a separate argu-
ment is only for POSIX compliance and is not recommended.)
It makes a difference where in the command you write this option; the linker searches and processes libraries
and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o
but before bar.o. If bar.o refers to functions in z, those functions may not be loaded.
The linker searches a standard list of directories for the library, which is actually a file named libli-
brary.a. The linker then uses this file as if it had been specified precisely by name.
The directories searched include several standard system directories plus any that you specify with -L.
Normally the files found this way are library files---archive files whose members are object files. The
linker handles an archive file by scanning through it for members which define symbols that have so far been
referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the
usual fashion. The only difference between using an -l option and specifying a file name is that -l sur-
rounds library with lib and .a and searches several directories.
-Ldir
Add directory dir to the list of directories to be searched for -l.
LIBRARY_PATH
The value of LIBRARY_PATH is a colon-separated list of directories, much like PATH. When configured as a
native compiler, GCC tries the directories thus specified when searching for special linker files, if it
can’t find them using GCC_EXEC_PREFIX. Linking using GCC also uses these directories when searching for
ordinary libraries for the -l option (but directories specified with -L come first).
#if 문이라던가 각종 전처리기용 문구들은
여러가지 확장을 통해서 컴파일을 하기 때문에 source insight 등의 힘을 빌려도 분석하기 어려운 면이 있다.
일반적으로 컴파일러는 전처리기 - 컴파일 - 어셈블 - 링크 과정을 거치는데(아마도?)
전처리기 까지만 거친 결과를 stdout 으로 출력해준다.
$ man gcc
-E Stop after the preprocessingstage; do not run the compiler proper.
The output is in the form of preprocessed source code, which is sent to the standard output.
Input files which don't require preprocessing are ignored.
--sysroot=dir
Use dir as the logical root directory for headers and libraries. For example, if the compiler would normally search for headers in /usr/include and libraries in /usr/lib, it will instead search dir/usr/include and dir/usr/lib.
If you use both this option and the -isysroot option, then the --sysroot option will apply to libraries, but the -isysroot option will apply to header files.
The GNU linker (beginning with version 2.16) has the necessary support for this option. If your linker does not support this option, the header file aspect of --sysroot will still work, but the library aspect will not.
-isysroot dir
This option is like the --sysroot option, but applies only to header files. See the --sysroot option for
more information.