`_IO_FILE' was not declared in this scope

I'm using a Huffman compression library implemented in c, and I'm having the following compilation error in c++ : _IO_FILE' was not declared in this scope . Sounds like I'm forgetting to include a certain .h . I know it sounds like an absolute beginner error, but I don't know what to do about it.

Here's the conflictive code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 *  huffman_coder - Encode/Decode files using Huffman encoding.
 *  http://huffman.sourceforge.net
 *  Copyright (C) 2003  Douglas Ryan Richardson
 */

#ifndef HUFFMAN_H
#define HUFFMAN_H

#include <stdio.h>

int huffman_encode_file(_IO_FILE *in, _IO_FILE *out);
int huffman_decode_file(_IO_FILE *in, _IO_FILE *out);
int huffman_encode_memory(const unsigned char *bufin,
						  unsigned int bufinlen,
						  unsigned char **pbufout,
						  unsigned int *pbufoutlen);
int huffman_decode_memory(const unsigned char *bufin,
						  unsigned int bufinlen,
						  unsigned char **bufout,
						  unsigned int *pbufoutlen);

#endif 
Last edited on
It's because the idiot who wrote the library used a non-standard, compiler-specific type instead of the standard FILE*.

You might want to search around the files and see what exactly he means by _IO_FILE. (If you can't find anything, then it is exactly as I first thought.)


BTW, I've been writing my own adaptive huffman encoder/decoder for fun. After I finish moving into the new house I'll finish it and post it here for you all. :-)
try "#include <libio.h>"

Ciao, Imi.
You motivated me to code a huffman tree class that works like this so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "basic_hufftree.hpp"
typedef basic_hufftree<unsigned char> hufftree;

#include <iostream>
#include <list>
#include <algorithm>
#include <iterator>

int main()
{
    using namespace std;
    const unsigned char str[] = "this is an example of a huffman tree";
    vector< pair<list<int>, unsigned char>  > char_table;
    vector< pair<list<int>, unsigned char>  >::const_iterator cit;    
    hufftree htree(hufftree::create_tree(str, sizeof(str)-1));

    char_table = htree.char_table();            
    for (cit = char_table.begin(); cit != char_table.end(); cit++) {
        cout << "(" << cit->second << ", ";
        copy(cit->first.begin(), cit->first.end(),
            ostream_iterator<int>(cout,""));
        cout << ")\n";
    }
}
(a, 111)
(e, 110)
(t, 1011)
(h, 1010)
(i, 1001)
(s, 1000)
(n, 0111)
(m, 0110)
(x, 01011)
(p, 01010)
(l, 01001)
(o, 01000)
(u, 00111)
(r, 00110)
(f, 0010)
( , 000)


This works pretty good. But here are two questions:

I assume that now i have to store the codes bitwise in a array, or file?
Is there any standard how to store a tree? i have a string representation, but thats not perfect.
e.g. i dont need to store everything i need to create the tree. Any Idea?


Maikel

try "#include <libio.h>"


libio.h: No such file or directory.

(yet.. i could download libio http://monkey.org/~provos/libio/ ,but i'd still need libevent http://monkey.org/~provos/libevent/ .Plus, I have no goddamn idea on how to make these two work)


You might want to search around the files and see what exactly he means by _IO_FILE. (If you can't find anything, then it is exactly as I first thought.)

_IO_FILE seems to be an old, c format. According to this link http://ldn.linuxfoundation.org/forum/linux-development-forum/topic/iofile-not-defined

 
As far as I can say, _IO_FILE is defined in stdio.h in the LSB headers.


Either that statement is a big lie (Because I'm already including stdio.h, and _IO_FILE is still not found) or I don't know how to do an include.

This is driving me nuts.
Last edited on
closed account (z05DSL3A)
the last time I saw _IO_FILE it was defined as:

typedef struct _IO_FILE FILE;
yeah, i've tried to change _IO_FILE to FILE . With that, i get rid of the undefined references, and the program seems to compile fine. However I'm having linker errors , which are explained here http://www.cplusplus.com/forum/windows/21655/
Last edited on
@Duoas
I'm the idiot who wrote the library. If you follow the sourceforge link and download a copy of the code, you'll see that FILE* is used, not _IO_FILE*. I don't know where JRevor got his code. It looks like he got code that was already pre-processed on a different OS.

@JRevor
Did you make modifications to that code? If not, where did you get it from?
I didn't do any modifications to the code. I got the code from a friend.

(Yeah, that might sound suspicious, but i remember downloading a version of the source code a couple of weeks ago, which had the same _IO_FILE thing. The problem is I don't remember the site)

I'll ask him where he got it, and I'll let you know.
This is the official site (at least as far as I'm concerned):
http://sourceforge.net/projects/huffman/
@mofochickamo
Sorry about that.

(Let me try to pull my foot out of my mouth.)

I presumed too much to think that the code was unmodified.

@Grey Wolf
Yes, some older systems (including, IIRC, the GCC) have FILE as a typedef for _IO_FILE (which is why I made my harsh comment). However, the C standards require a FILE, and nothing else, so portable code (such as a SourceForge Huffman compressor/decompressor) should not rely upon special knowledge of FILE's underlying structure -- which is meant to be something of a black box.

Sorry again that I didn't look at the source to verify that things matched up.

--Michael
Topic archived. No new replies allowed.