"too many initializers"

Posted on 2008-11-11
Last Modified: 2013-12-14

I get the compiler error C2078: too many initializers. Why ? I retyped the source, it does not seem anything like invisible characters causing the bug.

Here is the source extract, with the error located at line 9:
      HPDF_Page_BeginText (page);
      HPDF_Page_SetFontAndSize(page, "Helvetica", 10);
      HPDF_STATUS HPDF_Page_MoveTextPos
        ;// On this line, I get the following compiler error: error C2078: too many initializers
      HPDF_Page_ShowText (page, "Test text");
      HPDF_Page_EndText (page);

and here is the extract from the *.h file:
HPDF_Page_MoveTextPos  (HPDF_Page   page,
                        HPDF_REAL   x,
                        HPDF_REAL   y);
another extract:
typedef  float               HPDF_REAL;

This part of the program is supposed to write some text into a pdf which is being created by the libharu library. To include a jpeg into the pdf already works fine, but to write a title, I failed. I guess the problem is the c++ syntax, and not something around this libharu.

In a demo program, I see function calls such as  "HPDF_Page_MoveTextPos (page, x - 20, y - 25);", so I really cannot see any difference to what I did.

I am sure it is one of those tiny bugs you have no chance to find them after analysing it for too long. So I would apprechiate your fresh look :-)

Best regards, Sonja
Question by:Sonja_M
    LVL 6

    Assisted Solution

    Seems like the function returns a HPDF_STATUS?
    Do you want something like:
    HPDF_STATUS status = HPDF_Page_MoveTextPos(...) ?

    Author Comment

    Hello obrienslalom,

    thanks for your interesting answer.

    here is an extract from the demo program:
      HPDF_Page_BeginText (page);
      HPDF_Page_MoveTextPos (page, 60, height - 105);
      i = 0;
    as you see, there is no "status=HPDF_...".

    Also, if this would be the problem, I would expect another error message.
    I admit the source DOES compile when following your answer. But then I get an error at runtime. Summary: I guess your proposition corrects the bug just on the surface, it is a slalom around the deeper bug.

    Any ideas where to continue the search ?

    LVL 3

    Accepted Solution

    To expand on obrienslalom's comment, the reason you're getting the "too many initializers" error is that in your statement:

    HPDF_STATUS HPDF_Page_MoveTextPos(page, 0.00, 0.00);

    you're not calling a function, you're tying to declare a variable of type HPDF_STATUS with the name of HPDF_Page_MoveTextPos and with the parameters (page, 0.00, 0.00) passed to the constructor of HPDF_STATUS. This, obviously, doesn't work and isn't what you intended, hence the error.

    If you don't care about the return value, you can simply use:

    HPDF_Page_MoveTextPos(page, 0.00, 0.00);

    or save the result of the return HPDF_STATUS status = ... etc. (as mentioned above).

    As to why you're getting a runtime error, I can only speculate. Perhaps the "page" variable has not been properly set up?

    Author Comment


    melange wrote:
    >If you don't care about the return value, you can simply use:
    >HPDF_Page_MoveTextPos(page, 0.00, 0.00);
    yes, this is exactly what I wanted to do, but I failed: a bug when using copy-paste, and I was too blind to detect it.

    > As to why you're getting a runtime error, I can only speculate. Perhaps the "page" > variable has not been properly set up?
    I try to debug that myself, or ask a second question; it is off-topic here.

    so thanks to both the slalom master and the mixer who de-mixed my source.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (, we saw how to put the Delete button back there where it belongs.  "Delete" is …
    If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now