1

I've been stuck with this since last night, and for the life of me, I haven't been able to figure out why this is happening. I must be missing something very simple.

I'm making an OpenGL program. In this program, I'm making a DialogBox class. Below is the code:

//---------------------------------------------------------------
//DialogBox.h
//---------------------------------------------------------------

#include <vector>

class DialogBox
{
    private:

      float X; float Y; float Z;
      float Width;
      float Height;

      float RED;
      float GREEN;
      float BLUE;
      float ALPHA;

      int currentLine; 
      int maxLines;    //How many lines of text this dialog box can hold
      int maxChars;    //How many chars each line of text can hold

      std::vector< std::vector<char> >Text; //Text contents of the Dialog Box

      unsigned int vertexArray_DialogBox;
      unsigned int vertexBuffer_DialogBox;


   public:

      DialogBox();
      DialogBox(float width, float height);

      void draw();
      void draw(float x, float y, float z);

};

//------------------------------------------------------------------------
//DialogBox.cpp
//------------------------------------------------------------------------

#include <iostream>
#include "DialogBox.h"

DialogBox::DialogBox()
{
    X = 0.0f; Y = 0.0f; Z = 0.0f;

    Width = 1.0f;
    Height = 1.0f;

    RED = 0.0f;
    GREEN = 1.0f;
    BLUE = 1.0f;
    ALPHA = 1.0f;

    //For HELVETICA_18 ----------------------
    static const float letter_width = 0.03f;
    static const float letter_height = 0.04f;
    static const float line_height = 0.1f;
    //---------------------------------------


   maxLines = Height / line_height - 4; 
   maxChars = Width / letter_width - 2; 

   Text.resize(maxLines);
   for(int i = 0; i < maxLines; i++)
   {
       Text[i].resize(maxChars);
   }
}

DialogBox::DialogBox(float width, float height)
{
    Width = width;
    Height = height;
    //The rest of the initialization codes
}

void DialogBox::draw()
{
    //OpenGL Drawing codes
}

void DialogBox::draw(float x, float y, float z)
{
    X = x; Y = y; Z = z;
    draw();
}

And the compiler threw this error message:

enter image description here

I have been pulling my hairs out, but I couldn't figure out what the compiler were referring to. It must be something really simple (like a typo in the codes or something like that). Thank you in advance for your help.

2
  • Try renaming your class to a less likely name than DialogBox. Microsoft already provides something with that name. As an alternative, see if not including <iostream> or any system header helps. Jan 20, 2013 at 21:38
  • BINGO! Would you please post this as an Answer so I can accept it? Thank you very much!
    – TATN
    Jan 20, 2013 at 21:44

3 Answers 3

7

What's that warning on the same line?

not enough actual parameters for macro 'DialogBoxA'

Is DialogBox a #define-d macro? If so, that would probably mess things up.

5
  • This looks like a winner to me. Although I wonder how it became #defined when there's no trace of that in OP's code. Jan 20, 2013 at 21:37
  • No, I did not define DialogBox as a macro. I define it just like a normal C++ class. I don't know why it's showing that "macro" warning on the same line. The codes I showed you are everything I created regarding the DialogBox class.
    – TATN
    Jan 20, 2013 at 21:39
  • 2
    Are you including Windows.h at all? That has a DialogBox macro in it.
    – Steve
    Jan 20, 2013 at 21:46
  • Yeah, I included windows.h in the main.cpp file. That was probably the culprit of the problem. Thank you for pointing that out.
    – TATN
    Jan 20, 2013 at 21:52
  • Thank you, aschepler, for hinting out the root of the problem.
    – TATN
    Jan 20, 2013 at 22:17
3

Microsoft already provides a function (macro?) with the name DialogBox: http://msdn.microsoft.com/en-us/library/windows/desktop/ms645452%28v=vs.85%29.aspx

It probably got pulled in by <iostream>, <vector> or whatever. Renaming your class to a more original name should help.

1
  • I couldn't believe that I didn't think about something like this last night. It's so helpful to have a 2nd set of eyes looking at your codes sometimes. Thank you again!
    – TATN
    Jan 20, 2013 at 21:49
3

When I compile your code, I get an error on DialogBox::draw(), because you're not specifying the return type there. Specifically, this is on the implementation, not the declaration. That's the only compiler error I find in your code. Perhaps your compiler is just flagging the wrong line?

1
  • Oh, I missed the "void" before the draw() function when I copied my codes over. Sorry about that. I have edited and updated my codes on the first post.
    – TATN
    Jan 20, 2013 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.