Programming/C Win32 MFC2010. 10. 4. 18:04
한글로 번역이 잘못된건지 한글로는 모호하지만,
일단 정의(Definition)는 말그대로 어떠한 것을 정의"" 한다.
실제로 구체화/구현되지 않고, 설계도 라던가 단순하게 알려주는 역활을 한다.
하지만, 선언은 구체화를 한다. (메모리상에 자리를 차지한다)

그래서 우리가 변수를 만들때 "선언" 한다고 하고
구조체를 만들때 "정의" 한다고 했던 것이다.

[링크 : http://dstein.egloos.com/2563434]
[링크 : http://rookiecj.tistory.com/24]
[링크 : http://www.crazyowl.com/755]


----
으아아.. 지금보니 거꾸로 한게 맞네 ㅠ.ㅠ
딱다구리님 죄송합니다 ㅠ.ㅠ 

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

CFileDialog 말고 폴더 다이얼로그 없나?  (0) 2011.10.22
ctime()  (2) 2011.07.06
ini 파일 내용 파싱하기  (2) 2010.09.27
WinMain 과 DllMain  (0) 2010.09.09
수직탭이 모야? (what is the Vertical tab?)  (4) 2010.07.19
Posted by 구차니
Programming/C Win32 MFC2010. 9. 27. 22:00
머 언젠간 쓸일이 있겠지 -_-


GetPrivateProfileString()

[링크 : http://en.wikipedia.org/wiki/INI_file]
    [링크 : http://msdn.microsoft.com/en-us/library/ms724353%28VS.85%29.aspx]
Posted by 구차니
Programming/C++ STL2010. 9. 16. 10:07
new와 delete,
new[] 와 delete[] 가 묶여야 한다고 한다.

즉,
 int *a = new int;
 delete a;

 int *arr = new int[10];
 delete[] arr; // delete arr[]; 이 아님

그렇다고 해서 링크드 리스트 처럼 다층으로 메모리를 할당하는 구조에서는
delete[] 가 자동으로 해주진 않는것으로 보인다.
(그냥 STL 쓰면 해결된다는 지인의 조언이 -_-)

[링크 : http://yesarang.tistory.com/39]

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

c++ template  (0) 2012.05.12
리눅스에서 c++ 컴파일시 strcpy / strcat 오류  (0) 2011.10.13
cout 그리고 namespace  (0) 2010.09.16
C++ 레퍼런스 변수(reference variable)  (4) 2010.09.15
C++0x  (0) 2010.09.15
Posted by 구차니
Programming/C++ STL2010. 9. 16. 09:35
cout을 쓰려면
#include <iostream>
using namespace std;
두개를 써야 한다고 했는데, 문득 아래를 안쓰면 어떤 에러가 날지 궁금해졌다.

 error C2065: 'cout' : 선언되지 않은 식별자입니다.
음.. 역시 namespace가 다르니 인식을 하지 못하는 건가?

물론
std::cout << "Hello World";
라고 namespace를 직접 입력해주면 에러없이 실행이 가능하다.

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

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

리눅스에서 c++ 컴파일시 strcpy / strcat 오류  (0) 2011.10.13
new / new[] / delete / delete[]  (4) 2010.09.16
C++ 레퍼런스 변수(reference variable)  (4) 2010.09.15
C++0x  (0) 2010.09.15
std::vector 포인터  (0) 2010.09.13
Posted by 구차니
Programming/언어론2010. 9. 16. 09:15
포인터는 메모리의 특정 지점을 찍어주는 역활을 한다.
즉, 데이터든 코드든 어디든 찍을수가 있다.

함수 포인터에서 의문점이 생긴것은 바로 함수 포인터의 선언부분이다.
#include <stdio.h>

void testout1(const char *s) {
  printf("시험출력1:%s\n", s);
}

void testout2(const char *s) {
  printf("시험출력2:%s\n", s);
}

// 함수포인터 변수
void (*funcPtr)(const char *s);

int main() {
  // 함수포인터를 testout1, testout2로 각각 대입해보고 실행해본다.
  funcPtr = testout1;
  funcPtr("테스트");
  funcPtr = testout2;
  funcPtr("테스트");
}

[링크 : http://www.redwiki.net/wiki/wiki.php/%C7%D4%BC%F6%C6%F7%C0%CE%C5%CD]

위의 코드를 보면,
 void (*funcPtr)(const char* s);
위의 부분에서 함수 포인터의 인자(arguments)들의 형은 존재하지만, 변수명은 존재하지 않는 경우가 많다.

물론 VS2010 에서 컴파일을 해보아도
변수명이 존재를 하던 변수형만 존재를 하던 상관은 없지만 왜 그럴까? 라는 궁금증이 생겼다.

왜 그럴까?
아마도, 함수 포인터에서 중요한건 연결되는 함수와,
넘겨지는 변수들의 형, 그리고 갯수이지 변수명이 아니기 때문이 아닐까?

어짜피 stdcall 형태로 calling convention을 유지한다면
넘어가는 변수명 따위는 내부적으로는 의미가 없고, 넘어가는 순서가 중요하니 말이다.
그런 이유로, 함수 포인터의 선언에는 변수형만 존재하고 변수명은 옵션으로 존재하는 것으로 생각된다.

[링크 : http://www.cplusplus.com/doc/tutorial/pointers/]

'Programming > 언어론' 카테고리의 다른 글

dangling if-else  (0) 2014.08.13
double의 정확도 자릿수  (0) 2011.03.25
type system  (0) 2010.09.15
calling convention(콜링 컨벤션)  (0) 2010.04.17
Posted by 구차니
Programming/C++ STL2010. 9. 15. 13:06
int& a;
요 &가 바로 레퍼런스 변수이다.
어떻게 보면 포인터와 비슷하지만, 다른 녀석이고, C++ 공부중에 함수 인자에서 혼동을 느끼게 한 녀석이다.

// more than one returning value
#include <iostream>
using namespace std;

void prevnext (int x, int& prev, int& next)
{
  prev = x-1;
  next = x+1;
}

int main ()
{
  int x=100, y, z;
  prevnext (x, y, z);
  cout << "Previous=" << y << ", Next=" << z;
  return 0;
}

[링크 : http://www.cplusplus.com/doc/tutorial/functions2/]
[링크 : http://www.cplusplus.com/doc/tutorial/pointers/]

위의 소스중, prevent() 함수의 두/세번째 인자가 바로 reference 변수인데,
C에서는 당연히 포인터로 넘겨주어야 할꺼라고 생각을 했는데,
C++에서는 변수를 그냥 인자로 취해줌에도 불구하고 원본의 값이 바뀐다.
(당연히.. 레퍼런스 변수란걸 모르니 이상하게 보일수 밖에 ㅠ.ㅠ)

처음에는 자동형변환과 연관이 되어있나 했는데.. 그거랑은 거리가 좀 있는것 같고
그냥 단순히 C++ 문법적 특성으로 "참조형 변수" 라고 생각중 -_-

C++ 참조와 포인터의 차이점
- 만들어지면 값 변경불가
- 위의 이유로 null로 선언불가

C++ references differ from pointers in several essential ways:

  • It is not possible to refer directly to a reference object after it is defined; any occurrence of its name refers directly to the object it references.
  • Once a reference is created, it cannot be later made to reference another object; it cannot be reseated. This is often done with pointers.
  • References cannot be null, whereas pointers can; every reference refers to some object, although it may or may not be valid.
  • References cannot be uninitialized. Because it is impossible to reinitialize a reference, they must be initialized as soon as they are created. In particular, local and global variables must be initialized where they are defined, and references which are data members of class instances must be initialized in the initializer list of the class's constructor. For example:

[링크 : http://en.wikipedia.org/wiki/Reference_%28C%2B%2B%29]

[링크 : http://hijacker.egloos.com/1379523]
[링크 : http://www.cprogramming.com/tutorial/references.html]



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

new / new[] / delete / delete[]  (4) 2010.09.16
cout 그리고 namespace  (0) 2010.09.16
C++0x  (0) 2010.09.15
std::vector 포인터  (0) 2010.09.13
스마트 포인터(smart pointer)  (2) 2010.09.09
Posted by 구차니
Programming/언어론2010. 9. 15. 11:38
일반적으로 많이 접하는 '컴파일'언어들은 '형(type)'이 존재한다.
이러한 형의 존재를 type system 이라고 하고, 동적 형변환과 정적 형변환 그리고 강한 형검사, 약한 형검사로 나윈다.

음.. 결론은 없는 문제이지만,
강형(강한 형검사)/약형(약한 형검사)는 상대적인 것이라 나누는 것이 딱히 의미는 없어 보이고,
중요한건 동적 형 변환/정적 형 변환이냐의 차이가 아닐까 생각이 된다.

강한 형검사(strong typing)
 In computer science and computer programming, a type system is said to feature strong typing when it specifies one or more restrictions on how operations involving values of different data types can be intermixed. The opposite of strong typing is weak typing.

약한 형검사(weak typing)
 In computer science, weak typing (a.k.a. loose typing) is a property attributed to the type systems of some programming languages. It is the opposite of strong typing, and consequently the term weak typing has as many different meanings as strong typing does.

동적 형 변환(dynamic typing)
 A programming language is said to be dynamically typed when the majority of its type checking is performed at run-time as opposed to at compile-time. In dynamic typing, values have types but variables do not; that is, a variable can refer to a value of any type. Dynamically typed languages include Erlang, Groovy, JavaScript, Lisp, Lua, Objective-C, Perl (with respect to user-defined types but not built-in types), PHP, Prolog, Python, Ruby, Smalltalk and Tcl.

정적 형 변환(static typing)
 A programming language is said to use static typing when type checking is performed during compile-time as opposed to run-time. Statically typed languages include Ada, AS3, C, C++, C#, Eiffel, F#, Go, JADE, Java, Fortran, Haskell, ML, Objective-C, Pascal, Perl (with respect to distinguishing scalars, arrays, hashes and subroutines) and Scala. Static typing is a limited form of program verification (see type safety): accordingly, it allows many type errors to be caught early in the development cycle.

[링크 : http://kldp.org/node/55577]
[링크 : http://en.wikipedia.org/wiki/Statically_typed]
    [링크 : http://en.wikipedia.org/wiki/Statically_typed#Dynamic_typing]
    [링크 : http://en.wikipedia.org/wiki/Statically_typed#Static_typing]
[링크 : http://en.wikipedia.org/wiki/Weak_typing]
[링크 : http://en.wikipedia.org/wiki/Strong_typing]


언어별로 대충 훑어 보자면,
정적 형 변환 언어는 C 처럼 변수형을 지정하고 사용하는 언어이고
동적 형 변환 언어는 python이나 스크립트 처럼 변수형이 없이 변수명에 임의의 값을 넣고 사용하는 언어로 보인다.

'Programming > 언어론' 카테고리의 다른 글

dangling if-else  (0) 2014.08.13
double의 정확도 자릿수  (0) 2011.03.25
함수 포인터 (function pointer)  (0) 2010.09.16
calling convention(콜링 컨벤션)  (0) 2010.04.17
Posted by 구차니
Programming/C++ STL2010. 9. 15. 10:19
C99 이런것들 처럼 C++에 대한 표준안이지만 현재로서는 비공식 표준이다.
친구로는
C++98 (1998년 제정 표준)
C++03 (2003년 제정 표준)이 있다.
[링크 : http://en.wikipedia.org/wiki/C%2B%2B98#Language_standard]

[링크 : http://ko.wikipedia.org/wiki/C%2B%2B0x]
[링크 : http://en.wikipedia.org/wiki/C%2B%2B0x]

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

cout 그리고 namespace  (0) 2010.09.16
C++ 레퍼런스 변수(reference variable)  (4) 2010.09.15
std::vector 포인터  (0) 2010.09.13
스마트 포인터(smart pointer)  (2) 2010.09.09
C++ 강좌/문법/reference  (4) 2010.09.09
Posted by 구차니
Programming/C++ STL2010. 9. 13. 14:02
VC6.0 프로젝트를 VS2010으로 이전하다가, 코드는 아래와 같은데
std::vector<vectoriter>::iterator iter;
            vectoriter *pch = iter;

이런 에러가 발생이 되었다.
 error C2440: '초기화 중' : 'std::_Vector_iterator<_Myvec>'에서 'vectoriter *'(으)로 변환할 수 없습니다.

STL의 vector를 사용하는데, 어짜피 이녀석도 array로 호출은 되지만,
포인터 레벨의 차이인지 에러를 출력한다.
The usual way is &v[0]. (&*v.begin() would probably work too, but I seem to recall there's some fluffy wording in the standard that makes this not 100% reliable)

[링크 : http://stackoverflow.com/questions/1388597/stdvector-and-c-style-arrays]

 vectoriter *pch = &iter[0]; // no error
 vectoriter *pch = &iter; // error
흐음.. vector.begin() 역시 [0]과 같은 의미인것 같으나.. 여전히 템플릿은 머가먼지... OTL

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

C++ 레퍼런스 변수(reference variable)  (4) 2010.09.15
C++0x  (0) 2010.09.15
스마트 포인터(smart pointer)  (2) 2010.09.09
C++ 강좌/문법/reference  (4) 2010.09.09
STL 그리고 Template  (0) 2010.09.09
Posted by 구차니
Programming/android2010. 9. 11. 11:49
일반적으로 안드로이드 다운로드는 http://www.android.com/ 보다는 http://developer.android.com 에서 주로 받는데,
안드로이드 공식 홈페이지로 가면 Developers 옆에 Partners 라는 항목이 있다.


Developers는 말 그대로 어플리케이션 개발자를 위한 SDK를 제공하고
Partners는 안드로이드 플랫폼을 개발하기 위한 안드로이드 플랫폼을 제공한다.

# Required Packages:

    * Git, JDK, flex, and the other packages as listed above in the i386 instructions:
    * JDK 5.0, update 12 or higher.Java 6 is not supported, because of incompatibilities with @Override.
    * Pieces from the 32-bit cross-building environment
    * X11 development

[링크 : http://source.android.com/source/download.html]

아무튼, 이녀석을 위해서는 Git 가 필요하고, 오만가지 것들이 필요한데
MacOSX 와 Linux는 지원하지만 Windows는 지원하지 않는다.
게다가, git for windows는 cygwin 으로 작동해서 엄청난 속도를 자랑한 악몽이 있기에... OTL



생각보다 repo sync에서 시간이 엄청나게 오래 걸린다. 전체용량이 대략 2기가 정도를 받는데
git 임에도 불구하고 이렇게 오래 걸리다니..(대략 6시간 넘게 걸린듯..)

안드로이드 플랫폼(?)은 git를 깜산 python 스크립트로 작동되는 repo 라는 녀석으로 받아온다.
그리고 home 디렉토리의 ~/bin 에 repo를 설치한다.
개인적으로는 상대경로를 입력해서 repo를 실행했으나
repo 를 초기화 하면 .repo 라는 디렉토리가 생성되므로 /bin 에 넣는것 추천할만한 방법은 아니나
개인 계정에 설치하고 심볼릭 링크로 걸어도 상관은 없을듯 하다.

$ cd ~
$ mkdir bin
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo

안드로이드를 다운받기 위해서는 폴더를 하나 지정하고,
그 안에서 repo init 명령을 통해 초기화를 하고
repo sync 명령을 통해 다운로드 받는다.(6시간 정도 걸렸는데 네트워크 상황에 따라 달라질수 있음)
$ mkdir mydroid
$ cd mydroid
$ repo init -u git://android.git.kernel.org/platform/manifest.git

$ repo sync


이제 다 받았을뿐.. 컴파일을 시작해야 한다.
$ make


Posted by 구차니