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 7021867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:30:22+00:00 2026-05-27T23:30:22+00:00

This is my first question here, and the first time I haven’t been able

  • 0

This is my first question here, and the first time I haven’t been able to find a solution to a C++ problem online by just looking around. I’m relatively inexperienced in this area, and am not sure what’s relevant, so I’ll just post whatever I think might be useful.

I’m using SDL to make a cross-platform application. I’m using MinGW 4.6.1 on Windows 7 (64-bit), as well as an Ubuntu setup on another computer.

It compiles fine on Ubuntu (using g++) without any complaints, but I get the following error when I try to compile on my Windows machine with g++:

...matrix.cpp:77:17: error: expected primary-expression before '/' token
...matrix.cpp:78:11: error: expected primary-expression before '/' token
...matrix.cpp:79:17: error: expected primary-expression before ')' token
...matrix.cpp:79:28: error: expected primary-expression before ')' token
...matrix.cpp:80:19: error: expected primary-expression before ')' token
...matrix.cpp:80:30: error: expected primary-expression before ')' token

As far as I can tell, there’s nothing special in the function (especially since it compiles fine on my Ubuntu-setup):

Matrix *Matrix::projection(float near, float far, float top, float right) {
    x1 = near/right;
    y2 = near/top;
    z3 = -(far+near)/(far-near);
    z4 = -(2*far*near)/(far-near);
    w3 = -1.0;
    y1 = z1 = w1 =
    x2 = z2 = w2 =
    x3 = y3 =
    x4 = y4 = w4 = 0.0;
    return this;
}

In case it matters, here’s the Matrix class:

class Matrix { // row-major matrix
    public:
        float x1, y1, z1, w1, x2, y2, z2, w2, x3, y3, z3, w3, x4, y4, z4, w4;
        Matrix();
        Matrix (float a, float b, float c, float d, float e, float f, float g, float h, float i, float j, float k, float l, float m, float n, float o, float p);
        Matrix (float *f);
        Matrix *identity();
        Matrix *translation(float x, float y, float z);
        Matrix *rotation(float a, float i, float j, float k);
        Matrix *rotation(Quaternion q);
        Matrix *projection(float near, float far, float top, float right);
        Matrix operator*(Matrix m);
        void operator*=(Matrix m);
        Matrix operator/(float f);
        void operator/=(float f);
        Matrix operator*(float f);
        void operator*=(float f);
        void operator=(float *f);
        float *getArray();
};
  • 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-27T23:30:23+00:00Added an answer on May 27, 2026 at 11:30 pm

    My wild guess is that near and/or far are defined as macros, possibly so that ancient 16-bit DOS/Windows code can be compiled.

    Try adding #undef near and #undef far before your function and see if that helps.

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

Sidebar

Related Questions

This is my first question that I haven't been able to find an answer
Sorry, this's my first time to ask a question here. So, I don't have
this is my first time posting here, I have a question which I have
This is my first time here so I hope I post this question at
this is my first time asking a question here so apologies if I am
This is a pretty simple question; first time poster and long time looker. Here
this is my first question here on SO although I've been lurking for quite
This is the first time i'm asking a question here at stack overflow so
This is my first time using stackoverflow. I've been unable to find out the
Well this is not the first time im asking these question here but I

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.