프로그래밍/C2012. 11. 24. 11:13

결론부터 말하면, typedef 과 static은 storage class이기 때문에, 둘다 동시에 사용 못한다.

(우리가 변수를 int와 long으로 동시에 선언하지 못하듯이 말이다.)

 

또한 typedef은 변수를 instance화 시키는게 아니라, type을 선언하는 것이다.  반면에 static은 instance에 적용된다.

'프로그래밍 > C' 카테고리의 다른 글

typedef struct 안에서 스스로를 참조 할 때 주의점  (0) 2013.11.19
symbol visibility  (0) 2013.08.07
인라인 어셈블리  (0) 2012.09.25
include guard에 대해서  (0) 2012.09.24
구조체 초기화 방법  (0) 2012.08.21
Posted by code cat

Using GNU Make's 'define' and '$(eval)' to automate rule creation

About once a week I get an email from someone random asking a question about GNU Make. I do my best to answer and figured it might be helpful for others if I shared these questions and my answers. So, here goes. This one starts with a Princess Leia style appeal:
I stumbled across your name when googling for help on a GNUmake related problem, hope you have the time to look at it as you are my last hope. I have the following problem in my Makefile:
$(LIBDIR)/libfoo.a: $(filter $(OBJDIR)/foo/%,$(OBJECTS)) 
$(LIBDIR)/libbar.a: $(filter $(OBJDIR)/bar/%,$(OBJECTS)) 
$(LIBDIR)/libbaz.a: $(filter $(OBJDIR)/baz/%,$(OBJECTS)) 
  
$(LIBDIR)/%.a: 
        ar -r $@ $^ 
        ranlib $@
so far, so good - it works as expected. The only problem is, that in the real world it's not just foo, bar and baz for me and I hate having to maintain the list manually. What I would like to do is something like this:
$(LIBDIR)/lib%.a: $(filter $(OBJDIR)/%/%,$(OBJECTS)) 
        ar -r $@ $^ 
        ranlib $@
but now the pattern for filter has two percentage-characters and this seem to confuse GNUmake. I tried to escape it, use $(call …), etc. but nothing really works. Do you have any trick/hint/idea how to solve this??

Thanks for your time, Best Regards,
And my reply:
Thanks for your mail. I can see what you are trying to do. I think the easiest way out of your predicament is as follows:
# Example of manually maintained list 
# 
# $(LIBDIR)/libfoo.a: $(filter $(OBJDIR)/foo/%,$(OBJECTS)) 
# $(LIBDIR)/libbar.a: $(filter $(OBJDIR)/bar/%,$(OBJECTS)) 
# $(LIBDIR)/libbaz.a: $(filter $(OBJDIR)/baz/%,$(OBJECTS)) 
# 
# $(LIBDIR)/%.a: 
#        ar -r $@ $^ 
#        ranlib $@ 
 
# What you'd like to be able to do 
# 
# $(LIBDIR)/lib%.a: $(filter $(OBJDIR)/%/%,$(OBJECTS)) 
#        ar -r $@ $^ 
#        ranlib $@ 
 
# The following will work 
# 
# Suppose, for example: 
 
LIBDIR  := lib 
OBJDIR  := obj 
OBJECTS := $(OBJDIR)/foo/hello.o $(OBJDIR)/foo/bar.o $(OBJDIR)/bar/hello.o \ 
$(OBJDIR)/baz/bar.o 
 
# Extract the names of the first level directories underneath 
# $(OBJDIR) and make a unique list (sort removes duplicates) and store 
# that in LIBNAMES.  This assumes that there are no spaces in any of 
# the filenames in $(OBJECTS) and that each element of $(OBJECTS) 
# starts with $(OBJDIR) 
 
LIBNAMES := $(sort $(foreach a,$(patsubst $(OBJDIR)/%,%,$(OBJECTS)),\ 
$(firstword $(subst /, ,$a)))) 
 
# The following function finds all the objects in $(OBJECTS) in a 
# particular directory whose name can be found in LIBNAMES.  So, in 
# the example here doing $(call find-objects,foo) would return 
# obj/foo/hello.o obj/foo/bar.o 
 
find-objects = $(filter $(OBJDIR)/$1/%,$(OBJECTS)) 
 
# Now need to define the rule that handles each of the libraries 
# mentioned in $(LIBNAMES).  This function can be used with $(eval) to 
# define the rule for a single directory 
 
define make-library  
$(LIBDIR)/lib$1.a: $(call find-objects,$1) 
        ar -r $$@ $$^ 
        ranlib $$@ 
endef 
 
# Now define the rules for all the directories found in $(LIBNAMES) 
 
$(foreach d,$(LIBNAMES),$(eval $(call make-library,$d)))
You will need a version of GNU Make that supports $(eval).

 

Posted by code cat
XX XX 프로젝트2012. 11. 13. 09:01

일을 하다보면 remind 메일을 써야 할 때가 있다.  밑에 email을 참조해 보자.

Dear students:

This email is to remind of the meeting held today for the workshop you registered in previously. We will be discussing some issues regarding the timing and planning for the course. I look forward to seeing you all there. Below are the specific meeting details:

Time: (add time here)
Place: (enter name and address here)

Sincerely,
Your name

 

Posted by code cat

Bionic 이 지원안하고 안 할려는 리스트:

 

1. C++ exception (크고 느린 코드 생성원인)

2. pthread cancellation (C 코드 복잡성만 증가. 이런거에 의존하지 말고 multi-thread 코딩을 잘해라)

3. init 함수가 던진 c++ exception에 대한 pthread_once()지원 안함  (init함수가 하는 fork()도)

4. locale & wide characters (i18n을 위해 대신 ICU)

5. 유저 계정 관련 함수(getpwd 등)

Posted by code cat

a port of BSD C library to linux kernel with the following additions/changes:

- no support fo locales

- no support for wide chars (multi-byte characters)

- own smallish implementation of pthreads based on Linux futexes

- support fo x86, ARM, and ARM thumb cpu instruction sets and kernel interfaces

 

To add new syscalls:

Bionic provides the 'gensyscalls.py' script to automatically generate syscall stubs from the list defined in the file 'SYSCALLS.TXT'

To add a new syscall:

1. SYSCALL.TXT 수정

2. syscall에 대한 새로운 라인 추가:

return_type syscall_name(parameters)    syscall_number

3. syscall function과 entry name을 구분 짓고 싶으면:

return_type funcname:syscall_name(parameters)    syscall_number

4. 추가로 syscall number가 ARM 과 x86끼리 다르면,

return_type funcname[:syscall_name](parameters)    arm_number, x86_number

5. 플랫폼에 syscall이 구현안되었다고 나타내려면 -1을 사용하라.

void __set_tls(void*)    arm_number, -1     (예제)

 

자세한 내용은 SYSCALLS.TXT를 참조하고, 'checksyscalls.py'를 사용하여, syscall number를 제대로 사용하였는지 체크할 수도 있다.(리눅스 커널 헤더들안의 숫자와 비교한다.)

'안드로이드 > 프레임워크' 카테고리의 다른 글

[Android] OTA DownloadProvider document  (0) 2013.10.18
Bionic libc (3)  (0) 2012.11.08
Bionic libc  (0) 2012.10.30
안드로이드 init.rc (oom_adj값)  (0) 2012.09.27
Dalvik Virtual Machine 와 odex  (0) 2012.08.13
Posted by code cat