'Programming'에 해당되는 글 1721건

  1. 2015.07.19 lisp 키 입력
  2. 2015.07.14 void형 포인터 ++
  3. 2015.07.07 가변인자를 다시 넘겨주기 2
  4. 2015.06.24 std::endl
  5. 2015.06.18 printf 가변인자의 비밀?
  6. 2015.06.13 fasm / nasm / masm
  7. 2015.06.11 어셈블리 관련
  8. 2015.05.19 gcc 컴파일러 -D 옵션
  9. 2015.05.19 setjmp, longjmp
  10. 2015.05.19 코딩 룰 & 정적분석 툴
Programming/lisp2015. 7. 19. 22:36

(read)



.. 먼가 허무하네? -_-a


[링크 : http://www.tutorialspoint.com/lisp/lisp_input_output.htm]

'Programming > lisp' 카테고리의 다른 글

lisp 예제  (0) 2014.04.05
lisp 반복문 dolist, dotimes, do  (0) 2013.01.30
lisp cond  (0) 2013.01.28
lisp when/unless macro  (2) 2013.01.28
lisp 명령어 if progn  (0) 2013.01.28
Posted by 구차니
Programming/C Win32 MFC2015. 7. 14. 16:07



$ gcc -v

Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper

Target: x86_64-linux-gnu

Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu

Thread model: posix

gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 


$ vi void.c

#include <stdio.h>


void main()

{

        void *fp;

        int a = 0;

        fp = &a;


        printf("sizeof(void) %d\n",sizeof(void));

        printf("fp %8X\n",fp);

        fp++;

        printf("fp %8X\n",fp);

} 

(남자니까) 경고따윈 무시한다!

$ gcc void.c

void.c: In function ‘main’:

void.c:9:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat]

void.c:10:2: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘void *’ [-Wformat]

void.c:12:2: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘void *’ [-Wformat]


어? 연산이 되네? ㄷㄷㄷ 일단은 byte로 간주..

어? 게다가.. 왜 void의 sizeof가 1?

$ ./a.out
sizeof(void) 1
fp E9F5689C
fp E9F5689D


+

6.23 Arithmetic on void- and Function-Pointers


In GNU C, addition and subtraction operations are supported on pointers to void and on pointers to functions. This is done by treating the size of a void or of a function as 1.


A consequence of this is that sizeof is also allowed on void and on function types, and returns 1.


The option -Wpointer-arith requests a warning if these extensions are used.


[링크 : https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html]


+

Compiler Error CS0242

The operation in question is undefined on void pointers

Incrementing a void pointer is not allowed. For more information, see Unsafe Code and Pointers (C# Programming Guide).

[링크 : https://msdn.microsoft.com/en-us/library/dhyat531(v=vs.90).aspx] 


'Programming > C Win32 MFC' 카테고리의 다른 글

rand()와 RAND_MAX  (0) 2015.10.05
Cppcheck  (0) 2015.09.30
가변인자를 다시 넘겨주기  (2) 2015.07.07
printf 가변인자의 비밀?  (0) 2015.06.18
gcc 컴파일러 -D 옵션  (0) 2015.05.19
Posted by 구차니
Programming/C Win32 MFC2015. 7. 7. 13:45

현실적으로 불가능 -_-

다만 vsprintf 는 인자를 받으므로 인자를 이용해서 다시 문자열을 생성하는 식으로 쓸 수는 있음


[링크 : http://stackoverflow.com/questions/2060578/is-it-possible-to-write-a-varargs-function-that-sends-it-argument-list-to-anothe]


#include <stdio.h>

int printf(const char *format, ...);

int fprintf(FILE *stream, const char *format, ...);

int sprintf(char *str, const char *format, ...);

int snprintf(char *str, size_t size, const char *format, ...);


#include <stdarg.h>

int vprintf(const char *format, va_list ap);

int vfprintf(FILE *stream, const char *format, va_list ap);

int vsprintf(char *str, const char *format, va_list ap);

int vsnprintf(char *str, size_t size, const char *format, va_list ap);


[링크 : http://linux.die.net/man/3/vsprintf] 


'Programming > C Win32 MFC' 카테고리의 다른 글

Cppcheck  (0) 2015.09.30
void형 포인터 ++  (0) 2015.07.14
printf 가변인자의 비밀?  (0) 2015.06.18
gcc 컴파일러 -D 옵션  (0) 2015.05.19
setjmp, longjmp  (0) 2015.05.19
Posted by 구차니
Programming/C++ STL2015. 6. 24. 19:03

'\n' + fflush(stdout) 이라고 하면 되려나?


[링크 : http://www.cplusplus.com/reference/ostream/endl/]

[링크 : http://stackoverflow.com/questions/213907/c-stdendl-vs-n]

'Programming > C++ STL' 카테고리의 다른 글

cpp const  (0) 2016.06.22
const 멤버 변수 초기화(member variable initializer)  (0) 2016.06.22
c++ 현변환 연산자(cast operator in c++)  (0) 2015.01.26
functor / 펑터  (0) 2014.04.16
cpp static 변수 및 메소드  (0) 2014.03.18
Posted by 구차니
Programming/C Win32 MFC2015. 6. 18. 15:03

느낌적인 느낌으로는 가변인자는 가장 큰 변수형인 void 형을 취할테니..

printf 함수에서 %f를 double로 처리하면서 float에서는 오류가 발생하는 느낌?


아무튼.. 먼가 미묘한 작동을 하네..


[링크 : http://stackoverflow.com/questions/7295066/using-printf-to-print-out-floating-values]

[링크 : http://todayhumor.com/?programmer_11386]

'Programming > C Win32 MFC' 카테고리의 다른 글

void형 포인터 ++  (0) 2015.07.14
가변인자를 다시 넘겨주기  (2) 2015.07.07
gcc 컴파일러 -D 옵션  (0) 2015.05.19
setjmp, longjmp  (0) 2015.05.19
inline 함수..  (0) 2015.05.12
Posted by 구차니

Microsoft Macro ASseMbler

masm (16/32bit) / ml64 (64bit)

[링크 : https://en.wikipedia.org/wiki/Microsoft_Macro_Assembler]

[링크 : https://msdn.microsoft.com/en-us/library/afzk3475.aspx]


nasm

Netwide Assembler

[링크 : http://www.nasm.us/]

[링크 : https://en.wikipedia.org/wiki/Netwide_Assembler]


fasm

[링크 : http://flatassembler.net/]

[링크 : https://en.wikipedia.org/wiki/FASM]




[링크 : http://blog.naver.com/asmpro/220205244661]


'Programming > Assembly(어셈블리)' 카테고리의 다른 글

.text .data .code .bss ...  (0) 2016.02.19
어셈블리 관련  (0) 2015.06.11
ia32 어셈블리 언어  (0) 2013.12.12
.DATA? 지시어  (0) 2011.07.31
x86 register  (2) 2011.07.17
Posted by 구차니

다시 한번 도전!!! 해봐야지 ㅠㅠ


[링크 : http://todayhumor.com/?programmer_5407]

[링크 : http://stackoverflow.com/questions/8304914/difference-between-dword-ptr-and-dword-ptres]

[링크 : http://en.wikipedia.org/wiki/LOADALL]

[링크 : http://bbolmin.tistory.com/82]

'Programming > Assembly(어셈블리)' 카테고리의 다른 글

.text .data .code .bss ...  (0) 2016.02.19
fasm / nasm / masm  (0) 2015.06.13
ia32 어셈블리 언어  (0) 2013.12.12
.DATA? 지시어  (0) 2011.07.31
x86 register  (2) 2011.07.17
Posted by 구차니
Programming/C Win32 MFC2015. 5. 19. 14:35

배치빌드 하거나 할 경우 유용하게 쓰이는 옵션


-D name

Predefine name as a macro, with definition 1. 


-D name=definition

The contents of definition are tokenized and processed as if they appeared during translation phase three in a ‘#define’ directive. In particular, the definition will be truncated by embedded newline characters.

If you are invoking the preprocessor from a shell or shell-like program you may need to use the shell's quoting syntax to protect characters such as spaces that have a meaning in the shell syntax.


If you wish to define a function-like macro on the command line, write its argument list with surrounding parentheses before the equals sign (if any). Parentheses are meaningful to most shells, so you will need to quote the option. With sh and csh, -D'name(args...)=definition' works.


-D and -U options are processed in the order they are given on the command line. All -imacros file and -include file options are processed after all -D and -U options. 


-U name

Cancel any previous definition of name, either built in or provided with a -D option. 


-undef

Do not predefine any system-specific or GCC-specific macros. The standard predefined macros remain defined. 


[링크 : https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html] 


+

Visual studio에서는 /D로 적용된다.

[링크 : https://msdn.microsoft.com/ko-kr/library/teas0593.aspx]

'Programming > C Win32 MFC' 카테고리의 다른 글

가변인자를 다시 넘겨주기  (2) 2015.07.07
printf 가변인자의 비밀?  (0) 2015.06.18
setjmp, longjmp  (0) 2015.05.19
inline 함수..  (0) 2015.05.12
혼돈의 카오스 - 교차참조 헤더  (0) 2015.05.11
Posted by 구차니
Programming/C Win32 MFC2015. 5. 19. 10:03

setjmp와 longjmp는 함수를 넘나드는(다른 파일도 되려나?) 점프인데

goto 보다 더 위험한(!) 놈이라 잘 쓰지 않도록 되어 있는 것으로 보인다.

게다가 순수 C 구현이 아닌 OS 지원을 받는 넘이라 시스템 별로 다르게 작동 할지도 모른다고 ㄷㄷㄷ


코드로는 jmp_buf 는 점프할 지점을 저장하는 것이고

sizeof로 해보니 200을 뱉어낸다 ㄷㄷ (Ubuntu 12.04 64bit Edition)

PC(Program Counter) 뿐만 아니라 스택을 저장하는 거라 그런가?


코드상으로는 main()의 setjmp를 수행하는 지점이 돌아올 지점이고
longjmp에서 setjmp로 점프!
여러개의 setjmp로 여러 포인트를 잡아놓고
longjmp로 왔다 갔다 가능해 보이긴 하지만.. 까다로울 듯?

$ cat test.c

#include <stdio.h>

#include <setjmp.h>


jmp_buf pos;


void proc()

{

   static int i = 0;


   ++i;

   if(i<10)

       longjmp(pos, i);


   return;

}


int main()

{

   int a;


   a = setjmp(pos);

   printf("%d\n", a);

   proc();

   return 0;

}


[링크 : http://www.jiniya.net/wp/archives/5030]

[링크 : http://egloos.zum.com/studyfoss/v/5275830]


$ ./a.out
0
1
2
3
4
5
6
7
8
9



#include <setjmp.h>

int setjmp(jmp_buf env);

void longjmp(jmp_buf env, int val);


[링크 : http://linux.die.net/man/3/setjmp]

[링크 : http://linux.die.net/man/3/longjmp] 



'Programming > C Win32 MFC' 카테고리의 다른 글

printf 가변인자의 비밀?  (0) 2015.06.18
gcc 컴파일러 -D 옵션  (0) 2015.05.19
inline 함수..  (0) 2015.05.12
혼돈의 카오스 - 교차참조 헤더  (0) 2015.05.11
#ifdef 와 #ifdef ()의 차이  (0) 2015.04.13
Posted by 구차니



[링크 : http://www.oss.kr/oss_repository6/69515] 정적 분석 툴(오픈소스)

[링크 : http://biglook.tistory.com/16] 행정안전부 JAVA/C 코딩 룰

Posted by 구차니