Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 864749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:31:48+00:00 2026-05-15T09:31:48+00:00

I want to implement a function with OpenGL to render a cylinder in C++.

  • 0

I want to implement a function with OpenGL to render a cylinder in C++. The signature of my function is as follows:

#define POINTS_NUM  15
#define DEMESION    3
    
void drawCylinder( int slices, int segments, GLfloat (&vertices)[ POINTS_NUM ][ DEMESION ] );

I want to use a reference to a two-dimensional array to limit user input, but some strange behavior is happening. When I implement the function declared as above, an linker error occurs:

Error 1 error LNK2005: "float (* vase)[3]" (?vase@@3PAY02MA) already defined in shapes.obj vase.obj VaseAndAnimation

Here vase is defined as:

GLfloat vase[ POINTS_NUM ][ DEMESION ];

At first, I thought there was something wrong with the last dimension. So I omitted it in my second trial. This time declaration of my function is like this:

void drawCylinder( int slices, int segments, GLfloat (&vertices)[ POINTS_NUM ][] );

Now a compile-time error occurs when invoked as (vase definition isn’t changed):

drawCylinder( 10, 10, vase );

Compile error:

Error 1 error C2087: ‘vertices’ : missing subscript d:\visual studio 2008\projects\project1\computer graphics\vaseandanimation\shapes.h 25 VaseAndAnimation

Error 2 error C2664: ‘drawCylinder’ : cannot convert parameter 3 from ‘GLfloat [14][3]’ to ‘GLfloat (&)[14][1]’ d:\Visual Studio 2008\Projects\Project1\Computer Graphics\VaseAndAnimation\vase.cpp 64 VaseAndAnimation

Error 3 error C2087: ‘vertices’ : missing subscript d:\visual studio 2008\projects\project1\computer graphics\vaseandanimation\shapes.h 25 VaseAndAnimation

Error 4 error C2087: ‘vertices’ : missing subscript d:\Visual Studio 2008\Projects\Project1\Computer Graphics\VaseAndAnimation\shapes.cpp 12 VaseAndAnimation

From this error, I can see that parameter vertices is really treated a reference to a two-dimensional array, but why is vase parsed as float (* vase)[3] in my first version?

My IDE is Visual Studio 2008. I haven’t tried it with GCC; is that behavior compiler-dependent?

Hope someone can give me a hand to get rid of the trap.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:31:49+00:00Added an answer on May 15, 2026 at 9:31 am

    Your first declaration is fine. Seems to be you have defined vase in a header file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.