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

  • SEARCH
  • Home
  • 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 3481130
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:25:02+00:00 2026-05-18T10:25:02+00:00

I am trying to write some code to optimize some Open GL functions for

  • 0

I am trying to write some code to optimize some Open GL functions for a program I’m writing, unfortunately, I am not exactly a C or C++ veteran, but that’s partially why I’m doing this project!

So I’m creating a struct to handle 3×3 matrices and I am defining the struct as follows:

#ifndef MATRIX3BY3_H
#define MATRIX3BY3_H
struct Matrix3by3
{
    float ix, jx, kx;
    float iy, jy, ky;
    float iz, jz, kz;

    Matrix3by3() {}

    Matrix3by3(const Matrix3by3 &matrix)
    {
        ix = matrix.ix;
        jx = matrix.jx;
        kx = matrix.kx;

        iy = matrix.iy;
        jy = matrix.jy;
        ky = matrix.ky;

        iz = matrix.iz;
        jz = matrix.jz;
        kz = matrix.kz;
    }

    Matrix3by3 (const float _ix, const float _jx, const float _kx,
                const float _iy, const float _jy, const float _ky,
                const float _iz, const float _jz, const float _kz) :
        ix(_ix), jx(_jx), kx(_kx),
        iy(_iy), jy(_jy), ky(_ky),
        iy(_iz), jx(_jz), kz(_kz) {}
    }; 
#endif

And I get the error (twice)

Expected specifier-qualifier-list
before ‘Matrix3by3’

On the line of the first constructor. I have tried to look around for answers for this, and it seems that it has to do with the compiler not knowing that this is a type. So I have tried the following, I’ll remove the innards for brevity:

typedef struct Matrix3by3 { ... };

struct Matrix3by3 { struct Matrix3by3() {} ... };

struct Matrix3by3 { ... } Matrix3by3;

typdef struct Matrix3by3;
struct Matrix3by3 { ... };

Which are all solutions that were suggested on blogs and articles that I saw for this error. I also saw that it may arise because of a circular dependency, but this file has no includes that include anything else, and I’ve even removed them just to be certain from time to time – no change.

I could write this in a objective-c class, I’m sure, but it will probably take a tiny bit more memory and cycles, and that’s exactly what I’m trying to avoid. The only thing I can think of left is some compiler/project setting that I have set by default that precludes my using this type of structure. Entirely possible, as I’m learning the language/environment.

Can any one provide some help?

Thanks!

  • 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-18T10:25:03+00:00Added an answer on May 18, 2026 at 10:25 am

    C does not support constructors or member functions of structs. There is no way you will get this to compile as C or Objective-C. You need to compile this as C++ or Objective-C++, at which point it will almost compile: you have an error in your 3rd constructor, in that you’re attempting to initialize the members iy and jx multiple times. Once you fix those typos, it compiles just fine.

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

Sidebar

Related Questions

I was trying to write some code that would check if an item has
So, im trying to write some code that utilizes Nvidia's CUDA architecture. I noticed
I'm trying to write some C# code that calls a method from an unmanaged
I have a mobile platform that I am trying to write some communications code
I'm trying to write some LINQ To SQL code that would generate SQL like
I'm trying to write some code to find a specific XmlNode object based on
I'm trying to write some code to work with an htdigest password file. The
I'm trying to write some C# code to get to a specific folder in
I'm trying to write some SQL that will delete files of type '.7z' that
I am constantly trying to optimize my time. Writing a C code takes a

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.