?
Solved

order of dependant functions

Posted on 2003-02-18
3
Medium Priority
?
450 Views
Last Modified: 2008-02-01
hi, im new. i have written a little piece of code with two functions depending on eath other. one calls the other. now when i compile i get the:
*call to undefined function....*
when i change order the message is the same, just the other functions gets undefined. how can i get the compiler to trust me that @runtime both functions exist?? for better understanding here the code:

//---------------------------------------------------------------------------
signed char endcallback(FSOUND_STREAM *stream, void *buff, int len, int param)
{
    // end of stream callback doesnt have a 'buff' value, if it doesnt it could be a synch point.
    if (buff)
    {
        FSOUND_Stream_Close(stream);
        Form1->Edit1->Text="PENIS";
    }
    else
    {
        Form1->Edit1->Text="ZU ENDE!";
        index++;
        play((ListBox1->Items->Strings[index]).c_str());
    }

    return TRUE;
}
//----------------------------------------------------------------------------
void play(const char *filename)
{
FSOUND_Close();
FSOUND_Init(48000, 32, 0);
stream = FSOUND_Stream_OpenFile(filename, FSOUND_NORMAL| FSOUND_MPEGACCURATE | FSOUND_LOOP_OFF, 0);
FSOUND_Stream_Play(0, stream);
FSOUND_Stream_SetEndCallback(stream, endcallback, 0);
}
//---------------------------------------------------------------------------

in this order i get:

[C++ Error] main.cpp(31): E2268 Call to undefined function 'play'
[C++ Error] main.cpp(31): E2451 Undefined symbol 'ListBox1'

please help...
0
Comment
Question by:stoliD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:yury1854
ID: 7979052
Try this:

void play(const char *);

then the rest of your code.
0
 
LVL 2

Accepted Solution

by:
grue earned 150 total points
ID: 7979065
Prototype the functions at the top of the source file so that the compiler will "know" about the functions before they get used.

For example, put:

void play(const char *filename); // prototype

before your endcallback function.

The other error (ListBox1 is not defined) is because there is no ListBox1 declared in that function...  Maybe it's supposed to be a global (Like I'm guessing your "Form1" variable is), and you're spelling it wrong or something.

The error aside, I'm not sure if what you're trying to do is going to cause an infinite loop of some sort: it looks like your callback ("endcallback") is calling the function ("play") that started the thing that will generate another callback...  Is that what you want?

Also, I'm just going by function names here, but don't you want to define your callback before starting the process with "Play?"  It looks like you might want to change the order of the two lines:

FSOUND_Stream_Play(0, stream);
FSOUND_Stream_SetEndCallback(stream, endcallback, 0);

to

FSOUND_Stream_SetEndCallback(stream, endcallback, 0);
FSOUND_Stream_Play(0, stream);

but I'm just guessing because I don't know the library you're using.


0
 
LVL 1

Author Comment

by:stoliD
ID: 7980860
hi there its just a simple soundtest. the endcallback is a notify when a mp3playing stops, so its right after play(), or it doesnt really matter. Thanks for the prototype thingy guys, and grue, forgot the Form1-> before the listbox, ur answer accepted.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question