C++ 질문요...도와 주세요 T.T

kicom95의 이미지

인터넷을 돌아다니다가 괜찮은 소스를 하나 건졌습니다.

어디 까지나 주관적으로 괜찮은 소스 입니다.

제가 C 로만 계속 작업을 하다가 이번에 C++ 전향을 하고

있는데.... 거시기 소스가 VC++ 7.0 에서 컴파일 된거라

해서 올라 왔는데 UNIX 에서 컴파일이 잘 안되네요

그래서 안되는 부분이

1. )

implicit declaration of function `int Database::_fileno(...)'
BTreeDB.cpp:79: implicit declaration of function `int Database::_filelength(...)'
BTreeDB.cpp:81: implicit declaration of function `int Database::_chsize(...)'

에러인데

_fileno => fileno

_filelength ==> stat 으로 처리하면 될거 같구

근데 _chsize 는 뭐지요 ?

혹시 요 3개를 다 unix 용으로 가지고 있으시면 ^^

공개를 좀 부탁 드려두 ㅋㅋ

2. name lookup of `ctr' changed for new ANSI `for' scoping
BTreeDB.cpp:338: using obsolete binding at `ctr'

이런 메시지가 보입니다.

size_t ctr = 0;

for (ctr = 0; ctr < _minDegree - 1; ctr++)
{

}

이렇게 보이는데 이건 그냥 int 로 바꾸면 문제 없겠지요 ?

1.2 번은 제가 그런데로 처리를 하겠는데

알면서 물어 본다구 하시면 안되요 T.T

3. 요게 문제 입니다.

	typedef Database::Ptr<TreeNode> TreeNodePtr;
	typedef std::vector<TreeNodePtr> TREENODEVECTOR;
	typedef std::pair<TreeNodePtr, size_t> NodeKeyLocn;

이렇게 정의된 상황에서


	NodeKeyLocn BTreeDB::_search(const TreeNodePtr& node, const DbObjPtr& key, compareFn cfn)
	{
		NodeKeyLocn ret(TreeNodePtr(), (size_t)-1);


}


이 부분에서 에러가 나네요

BTreeDB.cpp: In method `struct Database::NodeKeyLocn Database::BTreeDB::_search(const Database::TreeNodePtr &, const Database::DbObjPtr &, int (*)(const Database::DbObjPtr &, const Database::DbObjPtr &) = 0)':
BTreeDB.cpp:91: parse error before `)'

제 생각에는

NodeKeyLocn ret(node, (size_t)-1);

로 하려구 하는데 고견을 듣구 싶네요 ^^

그것보다 VC 에서 위의 문법이 왜 허용되고

GCC (g++)에서는 허용이 안되는디... 알고 싶어요

참 혹시 이게 BTREE 라이브러리인데......

파일 DB 까지 지원하는거라서........

혹시 필요하시면

http://www.codeproject.com/database/btreedbclass.asp

를 참조하시면 됩니다.

[/code]

익명 사용자의 이미지

_chsize=character size(문자 크기)

kicom95의 이미지

1) 번은 아래와 같이 해결 했습니다.

#define _chsize(Handle,Size) ftruncate((Handle),(Size))
#define _fileno(_dataFile) fileno(_dataFile)

inline int _filelength(int fd)
{
struct stat sb;
return (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size);

}

역시 google 입니다.

2번은

for (size_t ctr = 0; ctr < _minDegree - 1; ctr++)
{

}

이렇게 되어 있는 부분을

size_t ctr = 0;

for (ctr = 0; ctr < _minDegree - 1; ctr++)
{

}

으로 고치면 되는군요

for( int i ... )

이렇게 선언되면

{

} 안에서 변수 i 를 사용할수 없는거 같네요

근데 아직 3번은 그렇게 뜯어 고쳣는데....

아직 정확한것인지 확신이 안 서요 ~~

대강 고친거 같기는 합니다만.

고견 부탁 드립니다 :)

가자 해외로 ~ .. 돈 벌러.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.