"too many initializers"


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
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Seems like the function returns a HPDF_STATUS?
Do you want something like:
HPDF_STATUS status = HPDF_Page_MoveTextPos(...) ?
Sonja_MAuthor Commented:
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 ?

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?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sonja_MAuthor Commented:

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.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.