How to fix these compiler errors?

I have this source code since 2001, which I would like to compile.

He gives the following:

$ make
g++ -O99 -Wall -DLINUX -pedantic   -c -o audio.o audio.cpp
In file included from audio.cpp:7:
audio.h:14: error: use of enum ‘mad_flow’ without previous declaration
audio.h:15: error: use of enum ‘mad_flow’ without previous declaration
audio.h:17: error: use of enum ‘mad_flow’ without previous declaration
audio.cpp: In function ‘mad_flow audio::input(void*, mad_stream*)’:
audio.cpp:19: error: new declaration ‘mad_flow audio::input(void*, mad_stream*)’
audio.h:14: error: ambiguates old declaration ‘int audio::input(void*, mad_stream*)’
audio.h:11: error: ‘size_t audio::stream::BufferPos’ is private
audio.cpp:23: error: within this context
audio.h:11: error: ‘size_t audio::stream::BufferSize’ is private
audio.cpp:23: error: within this context
audio.h:10: error: ‘char* audio::stream::Buffer’ is private
audio.cpp:26: error: within this context
audio.h:11: error: ‘size_t audio::stream::BufferSize’ is private
audio.cpp:26: error: within this context
audio.h:11: error: ‘size_t audio::stream::BufferPos’ is private
audio.cpp:27: error: within this context
audio.h:11: error: ‘size_t audio::stream::BufferSize’ is private
audio.cpp:27: error: within this context
audio.cpp: In function ‘mad_flow audio::output(void*, const mad_header*, mad_pcm*)’:
audio.cpp:49: error: new declaration ‘mad_flow audio::output(void*, const mad_header*, mad_pcm*)’
audio.h:15: error: ambiguates old declaration ‘int audio::output(void*, const mad_header*, mad_pcm*)’
audio.cpp: In function ‘mad_flow audio::error(void*, mad_stream*, mad_frame*)’:
audio.cpp:83: error: new declaration ‘mad_flow audio::error(void*, mad_stream*, mad_frame*)’
audio.h:17: error: ambiguates old declaration ‘int audio::error(void*, mad_stream*, mad_frame*)’
audio.cpp: In constructor ‘audio::stream::stream(const char*)’:
audio.cpp:119: error: ‘input’ was not declared in this scope
audio.cpp:122: error: ‘output’ was not declared in this scope
audio.cpp:123: error: ‘error’ was not declared in this scope
make: *** [audio.o] Error 1

audio.h contains

#ifndef _AUDIO_H_
#define _AUDIO_H_

#include <stdlib.h>
#include "mad.h"

namespace audio {
  class stream {
  private:
    char* Buffer;
    size_t BufferSize, BufferPos;
    struct mad_decoder Decoder;

    friend enum mad_flow input(void* Data, struct mad_stream* MadStream);
    friend enum mad_flow output(void* Data, const struct mad_header* Header,
                struct mad_pcm* PCM);
    friend enum mad_flow error(void* Data, struct mad_stream* MadStream,
                   struct mad_frame* Frame);

  public:
    stream(const char* FileName);
    ~stream();

    void play();
  };
}

#endif

Update:

The problem is what is mad_flownot visible. If I look in mad.h, then there is announced mad_flow.

If I just copy / paste

  enum mad_flow {
    MAD_FLOW_CONTINUE = 0x0000,
    MAD_FLOW_STOP     = 0x0010,
    MAD_FLOW_BREAK    = 0x0011,
    MAD_FLOW_IGNORE   = 0x0020
  };

from the mad.herror disappears (and new errors occur).

So, how do I make it mad_flowavailable?

+3
source share
2 answers

Regarding

I tried just pasting

enum mad_flow {};

... the correct forward type declaration mad_flowwould be:

enum mad_flow ;

, , , , . ?

[--- --- ]

, :

enum mad_flow ;             // forward declaration

void f( mad_flow& arg ) ;   // forward declaration of function 
                            // using incomplete type

int main()
{
    mad_flow x ;            // Declaration using incomplete type

    f( x ) ;                // Function call using incomplete enum object
}

enum mad_flow               // Completion of the definition
{
    VALUE1,
    VALUE2
} ;

void f( mad_flow& arg )
{
    arg = VALUE1 ;          // Use of value from complete definition
}
+2

https://docs.google.com/leaf?id=0BzqFMbU_9R0YMDI5ZjYzNDAtMTNkZC00YzYwLWE3N2UtYTFmNjdlM2ZiYTg5&hl=en_GB. INSTALL :

libpng >= 1.0.6, esound-devel Mesa >= 3.3. <URI:http://home.online.no/~loop/tsunami.html>. .

:
    make all

Run:
    ./demo

make all , . , url, INSTALL, , .

+1

Source: https://habr.com/ru/post/1739693/


All Articles