How to define global variable in vlc-0.8.6f?

This forum is about all development around libVLC.
christyyim
New Cone
New Cone
Posts: 4
Joined: 11 Jan 2009 18:07

How to define global variable in vlc-0.8.6f?

Postby christyyim » 11 Jan 2009 18:46

I wish to define a global variable as a counter to record how many times a hotkey button is pressed. The files that need to use this variable are the files vlc-0.8.6f/modules/control/hotkeys.c file, vlc-0.8.6f/modules/misc/network/ipv6.c file and vlc-0.8.6f/src/libvlc.c file. As you know, all these files are from different folders, how to define a global variable across these files?

I tried to declare the variable variable in 1 of the files and in the remaining 2 files I declared it as extern. However, this didn't work for me.
The error message I get was

Code: Select all

undefined reference to `counter'


Does anyone have any idea on it?

Thanks.

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

Re: How to define global variable in vlc-0.8.6f?

Postby Rémi Denis-Courmont » 17 Jan 2009 16:18

A true global variable - you'd need to put it in libvlc, and export it to plugins. But that is not possible in 0.8.6 and earlier, not thread-safe, and generally not supported on some platforms.

Usually we create a named VLC object variable onto the libvlc instance object with var_Create, var_Get and var_Set. There are plenty of examples throughout the source code.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 14 guests