c++ 컴파일 오류에 대해서 질문이 있습니다.

k3rnel의 이미지

안녕하세요.

dev-c++ (version 4.9.9.2) 컴파일러에서 다음과 같은 코드를 컴파일하는 과정에서
아래와 같은 에러가 발생하였습니다.

c++ 기반 지식이 부족한 상태에서 구글링 검색을 통해서 얻은 코드인데
발생한 에러가 어떤 의미인지 파악을 못하고 있습니다.

어떻게 수정해야 될까요? 도움 부탁드립니다.

typedef vector<unsigned char=""> BinaryArray;

8 missing `>' to terminate the template argument list
8 template argument 1 is invalid
8 template argument 2 is invalid
8 expected unqualified-id before '=' token
8 expected `,' or `;' before '=' token

아래는 전체소스입니다.

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
 
typedef vector<unsigned char=""> BinaryArray;
 
void usage();
bool read_binary(ifstream&, BinaryArray&);
unsigned output_hex(BinaryArray const &, unsigned const);
 
int main(int argc, char **argv) {
    if(argc < 2) {
        usage();
        return -1;
    }
 
    ifstream fin(argv[1], ios_base::binary);
    if(!fin) {
        cerr << "failed to open file \"" << argv[1]
             << "\".\n";
        return -1;  
    }
 
    BinaryArray array;
    if(!read_binary(fin, array)) {
        cerr << "failed to parsed file \"" << argv[1] 
             << "\".\n";
        return -1;
    }
 
    unsigned count_per_line = 16;
    if(argc >= 3) count_per_line = atoi(argv[2]);
    cout << "//Reading \"" << argv[1] << "\"\n"
         << "//Size: " << array.size() << " bytes\n"
         << "//Count per line: " << count_per_line 
         << "\n";
    unsigned null_count = output_hex(array, count_per_line);
    cout << "//NULL count: " << null_count << '\n';
}
 
unsigned output_hex(BinaryArray const &carr, unsigned const cpl) {
    unsigned null = 0;
    cout << "char code[] = \n\"";
    for(size_t i = 1; i <= carr.size(); ++i) {
        cout << "\\x" << hex << setw(2) 
             << setfill('0') << (unsigned)(carr[i-1]);
        if(!(i % cpl)) {
            cout << "\"\n";
            if(i < carr.size()) cout << '\"';
        }
        if(!(carr[i-1])) ++null;        
    }
 
    if(carr.size() % cpl) cout << '\"';
    cout << ";\n";
    return null;
}
 
bool read_binary(ifstream& fin, BinaryArray& arr) {
    try {
        unsigned file_length;
 
        fin.seekg(0, ios::end);
        file_length = fin.tellg();
        fin.seekg(0, ios::beg);
 
        arr.resize(file_length);
        char *mem_buf = new char [file_length];
        fin.read(mem_buf, file_length); 
        copy(mem_buf, mem_buf+file_length, arr.begin());
        delete [] mem_buf;
    } catch(...) {return false;}
    return true;
}
 
void usage() {
    cout << "Usage: fonReadbin <asm_bin_file> [count_per_line=16]\n"
}
익명 사용자의 이미지

typedef vector<unsigned char=""> BinaryArray;

unsigned char 뒤에 =""이 왜 들어가 있나요? 그 세 글자를 지우고 다시 컴파일해 보세요.

아울러 Dev-C++는 개발이 중단된지 오래되었고 거기에 들어 있는 컴파일러도 상당히 오래된 버전입니다. 다른 환경을 사용하기를 추천합니다.

k3rnel의 이미지

말씀하신대로 char뒤에 ="" 이 부분을 지우고 하니 컴파일도 잘되고
생성된 실행파일도 정상적으로 잘 동작합니다. 감사합니다.

아울러 dev-c++에 대해서 조언해주신 부분도 감사합니다.
제가 개인적으로 오래된 환경에서 테스트할 상황이어서 dev-c++ 오래된 버전을 사용하고 있습니다.^^

감사합니다. 덕분에 짧은 시간안에 문제를 해결할 수 있었습니다. 감사합니다.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.