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

Author Topic: incompatible type for argument 4 of ‘sfWindow_Create’  (Read 10707 times)

0 Members and 2 Guests are viewing this topic.

Hohoo

  • Newbie
  • *
  • Posts: 13
    • View Profile
incompatible type for argument 4 of ‘sfWindow_Create’
« on: April 22, 2010, 02:32:28 pm »
I'm writing my Vala bindings, but something seems to be wrong. On line 27 (if (sfVideoMode_IsValid (&vm))) I get this error:
Quote
test.c:27: error: incompatible type for argument 1 of ‘sfVideoMode_IsValid’


(For those who don't know: Vala is translated into C first and then compiled.)

Here is the code:
Code: [Select]
/* test.c generated by valac, the Vala compiler
 * generated from test.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <SFML/Window.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>




gint _vala_main (char** args, int args_length1);



gint _vala_main (char** args, int args_length1) {
gint result = 0;
sfContextSettings _tmp0_ = {0};
sfContextSettings cs;
sfVideoMode _tmp1_ = {0};
sfVideoMode vm;
cs = (_tmp0_.DepthBits = (guint) 800, _tmp0_.StencilBits = (guint) 600, _tmp0_.AntialiasingLevel = (guint) 32, _tmp0_.MajorVersion = (guint) 2, _tmp0_.MinorVersion = (guint) 0, _tmp0_);
vm = (_tmp1_.Width = (guint) 320, _tmp1_.Height = (guint) 240, _tmp1_.BitsPerPixel = (guint) 32, _tmp1_);
if (sfVideoMode_IsValid (&vm)) {
fprintf (stdout, "%d\n", (gint) cs.MajorVersion);
}
result = (gint) sfNone;
return result;
}


int main (int argc, char ** argv) {
g_type_init ();
return _vala_main (argv, argc);
}





Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
incompatible type for argument 4 of ‘sfWindow_Create’
« Reply #1 on: April 22, 2010, 02:34:31 pm »
The compiler is right, sfVideoMode_IsValid doesn't want a pointer.
Code: [Select]
sfVideoMode_IsValid (vm)
Laurent Gomila - SFML developer

Hohoo

  • Newbie
  • *
  • Posts: 13
    • View Profile
incompatible type for argument 4 of ‘sfWindow_Create’
« Reply #2 on: April 22, 2010, 02:37:43 pm »
Quote from: "Laurent"
The compiler is right, sfVideoMode_IsValid doesn't want a pointer.
Code: [Select]
sfVideoMode_IsValid (vm)

Ok, but when I do that, I get this error instead:
Quote
undefined reference to `sfVideoMode_IsValid'

Even though I linked to sfml-window and sfml-system

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
incompatible type for argument 4 of ‘sfWindow_Create’
« Reply #3 on: April 22, 2010, 02:40:13 pm »
You must link to csfml-window and csfml-system.
Laurent Gomila - SFML developer

Hohoo

  • Newbie
  • *
  • Posts: 13
    • View Profile
incompatible type for argument 4 of ‘sfWindow_Create’
« Reply #4 on: April 22, 2010, 02:53:14 pm »
Eh
Quote
./test: error while loading shared libraries: libsfml-window.so.1.5: cannot open shared object file: No such file or directory

I'm using SFML2 but it seems to be looking for an ancient version...

EDIT: Fixed; turned out there was something wrong with my CSFML libs.

Hohoo

  • Newbie
  • *
  • Posts: 13
    • View Profile
incompatible type for argument 4 of ‘sfWindow_Create’
« Reply #5 on: April 22, 2010, 07:28:19 pm »
Sorry for the double post, but I have no idea what's going on with this code:
Code: [Select]
/* test.c generated by valac, the Vala compiler
 * generated from test.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <SFML/Window.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define _sfWindow_Destroy0(var) ((var == NULL) ? NULL : (var = (sfWindow_Destroy (var), NULL)))



gint _vala_main (char** args, int args_length1);



static sfContextSettings sfml_window_create_context_settings (guint depth_bits, guint stencil_bits, guint antialiasing_level, guint major_version, guint minor_version) {
sfContextSettings result;
sfContextSettings _tmp0_;
result = (_tmp0_.DepthBits = depth_bits, _tmp0_.StencilBits = stencil_bits, _tmp0_.AntialiasingLevel = antialiasing_level, _tmp0_.MajorVersion = major_version, _tmp0_.MinorVersion = minor_version, _tmp0_);
return result;
}


gint _vala_main (char** args, int args_length1) {
gint result = 0;
sfContextSettings cs;
sfVideoMode _tmp0_;
sfVideoMode vm;
sfWindow* w;
cs = sfml_window_create_context_settings ((guint) 800, (guint) 600, (guint) 32, 2, 0);
vm = (_tmp0_.Width = (guint) 320, _tmp0_.Height = (guint) 240, _tmp0_.BitsPerPixel = (guint) 32, _tmp0_);
if (sfVideoMode_IsValid (vm)) {
fprintf (stdout, "%d\n", (gint) cs.MajorVersion);
}
w = sfWindow_Create (vm, "Hej!", sfDefault, cs);
result = (gint) sfNone;
_sfWindow_Destroy0 (w);
return result;
}


int main (int argc, char ** argv) {
g_type_init ();
return _vala_main (argv, argc);
}





I'm getting these errors:
Quote
test.vala.c: In function ‘_vala_main’:
test.vala.c:39: error: incompatible type for argument 4 of ‘sfWindow_Create’
/usr/local/include/SFML/Window/Window.h:75: note: expected ‘const struct sfContextSettings *’ but argument is of type ‘sfContextSettings’

I don't see any sfContextSettings* there.

EDIT: Fixed again. I need to be more careful.

Hohoo

  • Newbie
  • *
  • Posts: 13
    • View Profile
incompatible type for argument 4 of ‘sfWindow_Create’
« Reply #6 on: April 22, 2010, 11:05:07 pm »
By the way, what's wrong with this code?
Code: [Select]
static sfWindow* sfml_window_window_new_simple (sfVideoMode mode, const char* title) {
sfContextSettings _context_settings;
g_return_val_if_fail (title != NULL, NULL);
memset (self, 0, sizeof (sfWindow));
_context_settings = sfml_window_create_context_settings ((guint) 24, (guint) 8, 0, 2, 0);
self = (sfWindow*) sfWindow_Create (mode, title, sfDefaultStyle, &_context_settings);
}

Quote

31: error: ‘self’ undeclared (first use in this function)
31: error: (Each undeclared identifier is reported only once
31: error: for each function it appears in.)
31: error: invalid application of ‘sizeof’ to incomplete type ‘sfWindow’

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
incompatible type for argument 4 of ‘sfWindow_Create’
« Reply #7 on: April 23, 2010, 08:45:25 am »
What is self? Where is it declared?
Laurent Gomila - SFML developer

Hohoo

  • Newbie
  • *
  • Posts: 13
    • View Profile
incompatible type for argument 4 of ‘sfWindow_Create’
« Reply #8 on: April 23, 2010, 09:20:25 am »
Quote from: "Laurent"
What is self? Where is it declared?

That appeared to be a Vala bug. But it seems that self is declared on the last line.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
incompatible type for argument 4 of ‘sfWindow_Create’
« Reply #9 on: April 23, 2010, 01:42:42 pm »
Quote from: "Hohoo"
But it seems that self is declared on the last line.
No, that's not a declaration, rather an assignment.

Sometimes it helps to carefully read the error message... ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything