Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sfFloatRect_set function  (Read 6667 times)

0 Members and 1 Guest are viewing this topic.

c-jay

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
sfFloatRect_set function
« on: April 26, 2016, 03:24:47 pm »
Hi this works fine:

#include <SFML/Graphics.h>

sfVector2f sfVector2f_set(float x, float y){
        sfVector2f vector2f;

        vector2f.x = x;
        vector2f.y = y;

        return vector2f;
}

int main(){
sfVector2f vector;
vector.x = sfVector2f_set(1, 1).x;
}
 
But this throws error: request for member top in something not a structure or union
#include <SFML/Graphics.h>
sfFloatRect sfFloatRect_set(float top, float left, float width, float height){
        sfFloatRect floatRect;

        floatRect.top = top;
        floatRect.left = left;
        floatRect.width = width;
        floatRect.height = height;

        return floatRect;
}

int main(){
sfFloatRect floatRect;

// throws error: request for member top in something not a structure or union      
floatRect.top = sfFloatRect_set(1,1,1,1).top;              
                                                       
}
 

I think it could be a basic c problem but i'm very thankful for a reason.
« Last Edit: April 26, 2016, 07:37:16 pm by c-jay »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sfFloatRect_set function
« Reply #1 on: April 26, 2016, 03:30:32 pm »
"doesn't work" is a very bad description of your problem. Please give the exact compiler error, as well as the corresponding line in source code.
Laurent Gomila - SFML developer

c-jay

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: sfFloatRect_set function
« Reply #2 on: April 26, 2016, 03:44:02 pm »
I'm very sorry, I edited my post with an description

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: sfFloatRect_set function
« Reply #3 on: April 26, 2016, 06:05:23 pm »
With the exception of main's return type being int (google why), this works just fine.
SFML / OS X developer

c-jay

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: sfFloatRect_set function
« Reply #4 on: April 26, 2016, 06:54:29 pm »
With the exception of main's return type being int (google why).
i fixed it in the main post but my code still throw the same error
« Last Edit: April 26, 2016, 07:34:32 pm by c-jay »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10930
    • View Profile
    • development blog
    • Email
Re: sfFloatRect_set function
« Reply #5 on: April 26, 2016, 07:10:05 pm »
And the error would be...? ::)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

c-jay

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: sfFloatRect_set function
« Reply #6 on: April 26, 2016, 07:36:39 pm »
And the error would be...? ::)

// throws error: request for member top in something not a structure or union      
floatRect.top = sfFloatRect_set(1,1,1,1).top;      
 
         

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sfFloatRect_set function
« Reply #7 on: April 26, 2016, 08:18:16 pm »
Is it the actual code that gives you the error, or is it a simplified version for the forum, that you never compiled?
Laurent Gomila - SFML developer

c-jay

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: sfFloatRect_set function
« Reply #8 on: April 28, 2016, 05:45:45 pm »
Is it the actual code that gives you the error, or is it a simplified version for the forum, that you never compiled?

Thank you very much! I forgot to declare the prototype...  :-[

 

anything