Reputation: 2043
i have a c-file containing some dbus stuff and implementing the dbus.h. this is working fine so far. now i intent to split my c-file in a c-file and a header-file. but now - the compile process failes with:
gcc -o dbus `pkg-config --cflags --libs dbus-1` dbus.c
In file included from dbus.c:1:0:
dbus.h:12:27: error: unknown type name ‘DBusMessage’
dbus.h:12:45: error: unknown type name ‘DBusConnection’
dbus.c: In function ‘dbus_send_signal’:
dbus.c:8:4: error: unknown type name ‘DBusMessage’
dbus.c:9:4: error: unknown type name ‘DBusMessageIter’
...
i just split the former c-file like this:
#include "dbus.h" // include local dbus.h
/**
* Connect to the DBUS bus and send a broadcast signal
*/
void dbus_send_signal(char* sigvalue)
{
DBusMessage* msg;
DBusMessageIter args;
DBusConnection* conn;
...
and the local-header dbus.h file:
#ifndef DBUS_H
#define DBUS_H
#include <dbus/dbus.h> // include the global dbus.h
#include <stdbool.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
void dbus_listen();
void dbus_send_signal(char *sigvalue);
...
i didn't change the code itself so i am a little bit confused. just splitting the content in a c- and h-file. have u an idea? are the gcc parameters wrong?
Upvotes: 0
Views: 3316
Reputation: 6877
It's just a guess, but perhaps <dbus/dbus.h> also contains
#ifndef DBUS_H
#define DBUS_H
You need to make them not the same, e.g. change your local one to
#ifndef LOCAL_DBUS_H
#define LOCAL_DBUS_H
Upvotes: 5