compiling with libvlc 2.0 in Windows

This forum is about all development around libVLC.
ghell
Blank Cone
Blank Cone
Posts: 10
Joined: 09 Nov 2008 14:41

compiling with libvlc 2.0 in Windows

Postby ghell » 30 Jun 2012 02:03

Compiling as C in visual studio 10 with 2.0.1 headers, anything that #includes libvlc.h.


In libvlc.h:

Code: Select all

static inline int64_t libvlc_delay(int64_t pts)
needs to be changed to

Code: Select all

static int64_t libvlc_delay(int64_t pts)
to work (no inline)



In libvlc_media_player.h:

Code: Select all

# include <stdbool.h>
needs to be changed to

Code: Select all

typedef int bool;
to work (no stdbool.h)


OR

Code: Select all

typedef void (*libvlc_audio_set_volume_cb)(void *data, float volume, bool mute);
needs to be changed to

Code: Select all

typedef void (*libvlc_audio_set_volume_cb)(void *data, float volume, int mute);
to work (bool to int)






These issues did not exist on older versions (e.g 1.1.11).

They are still there in the current git.

I assume they cause the same issues on other platforms but compiling as C99 solves them there (inline is C99 and stdbool.h just doesn't exist here). It seems like a strange hurdle to add for little to no benefit though.

Rémi Denis-Courmont
Developer
Developer
Posts: 15323
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: compiling with libvlc 2.0 in Windows

Postby Rémi Denis-Courmont » 30 Jun 2012 13:07

Your changes are not valid. bool is not the same as int, not in general and not even on any single platform.

You need a proper compiler.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

ghell
Blank Cone
Blank Cone
Posts: 10
Joined: 09 Nov 2008 14:41

Re: compiling with libvlc 2.0 in Windows

Postby ghell » 30 Jun 2012 15:34

Your changes are not valid. bool is not the same as int, not in general and not even on any single platform.

You need a proper compiler.
I was originally using an 8 bit integer as I assumed bool would be (smallest allocable unit), until I noticed that the typedef in stdbool.h, which is what you're using, actually uses a 32 bit integer.

Code: Select all

#define false 0 #define true 1 #define bool _Bool #if __STDC_VERSION__ < 199901L && __GNUC__ < 3 && !defined(__INTEL_COMPILER) typedef int _Bool; #endif
bool is _Bool and _Bool is int (so bool is transitively int)


"true" and "false" can also cause problems if other values are used. For example:

Code: Select all

bool b; b = 2; if(b != true && b != false) { /* This actually runs, a bool can be neither true nor false */ }
while the standard convention for true in C is "not zero", and this is also what is used elsewhere (e.g. "do_pause: play/resume if zero, pause if non-zero")


There is also already an existing convention everywhere else in libvlc that uses an int in place of a bool, for example

Code: Select all

int libvlc_media_player_is_playing( libvlc_media_player_t *p_mi )

Code: Select all

int libvlc_media_player_is_seekable( libvlc_media_player_t *p_mi )

Code: Select all

void libvlc_media_player_set_pause( libvlc_media_player_t *p_mi, int paused )
This is the *only* place where the type "bool" is used, and it typedefs back to an int anyway, so there is not even any reason to use it. The code should also be consistent.

It only causes problems and does not improve anything.



"inline" does actually make a difference but this single keyword that occurs once in the source is the only thing that requires C99 to compile, and generally in C the same thing is achieved with preprocessor macros, while "inline" is generally only used in C++. From what I've heard "inline" also has a slightly different definition in gcc before and after C99 when it was added to the spec, which could cause unexpected changes in behaviour, although I don't know enough about this to talk in detail of the changes.


So, my changes are both valid and improvements. libvlc is as close to a perfect library as I have ever seen and I'd just like it to stay that way. These very minor changes have only existed since 2.0.x. There were no issues in 1.1.x

These problems affect anyone who tries to use libvlc.h (2.0.x) in their visual studio project (pretty much everyone who tries to use it on Windows). It is not just when compiling libvlc itself. I also suggested very small improvements rather than idly complaining without offering any suggestions. Hopefully I've given a reasonable argument for these suggestions and you will consider them.

Also, please try to be less condescending when you post.

Rémi Denis-Courmont
Developer
Developer
Posts: 15323
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: compiling with libvlc 2.0 in Windows

Postby Rémi Denis-Courmont » 01 Jul 2012 11:14

bool is _Bool and _Bool is not int. The ISO C specification contradicts you.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

RSATom
Big Cone-huna
Big Cone-huna
Posts: 513
Joined: 24 Nov 2011 06:55
Operating System: Windows/Linux/OsX
Location: Russia, Tomsk

Re: compiling with libvlc 2.0 in Windows

Postby RSATom » 01 Jul 2012 12:23

why not just compile your sources as c++?

ghell
Blank Cone
Blank Cone
Posts: 10
Joined: 09 Nov 2008 14:41

Re: compiling with libvlc 2.0 in Windows

Postby ghell » 02 Jul 2012 01:40

I'm surprised you're putting up so much resistance to defend an obvious flaw in the library that is easily fixed but whatever, it's your library and if you're going to start suddenly introducing silly problems like this now (likely just because you don't like people pointing them out to you), who am I to stop you?
why not just compile your sources as c++?
Because it happens when you #include libvlc.h in your existing project, not just when trying to compile libvlc. Not only should you not have to change your project to C++ in order to use a C library, in some cases you can't.

Rémi Denis-Courmont
Developer
Developer
Posts: 15323
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: compiling with libvlc 2.0 in Windows

Postby Rémi Denis-Courmont » 02 Jul 2012 09:48

I am surprised that you put up so much resistance to defend an obvious flaw in your compiler. C99 has been out for, hmm, 12 years. VLC has required it for over 5 years.

We do not change the LibVLC function prototypes. That would break binary compatibility for everybody (else) using sane compilers like, hmm... GCC, LLVM/clang, Intel, Sun...
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: compiling with libvlc 2.0 in Windows

Postby Jean-Baptiste Kempf » 03 Jul 2012 17:39

I'm surprised you're putting up so much resistance to defend an obvious flaw in the library that is easily fixed but whatever, it's your library and if you're going to start suddenly introducing silly problems like this now (likely just because you don't like people pointing them out to you), who am I to stop you?
why not just compile your sources as c++?
Because it happens when you #include libvlc.h in your existing project, not just when trying to compile libvlc. Not only should you not have to change your project to C++ in order to use a C library, in some cases you can't.
libVLC is not a C library, it is a C99 library.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 5 guests