Hi,
On 2013-01-13 14:33, Matthias Janke wrote:
Beeing lazy is one motivaton for the patch. The other one is that
compiling an application is differnt from linking. When you link
libusb is proxied by libftdi, since libftdi is linked against libusb,
so on the linker cmd line there is only -lftdi1. So you don't care
about
libusb/x at all. But when you compile you have to include libusb
explicitly even if you don't use it in your application. This
breaks abstraction layers.
IMHO it would be better to not include <libusb.h> at all when compiling
your application (unless the application needs it directly).
The attached patch removes said include from the exposed header ftdi.h
and instead includes libusb.h in the libftdi sources where needed -
ftdi.h itself did not need the declarations from libusb.h.
(Caveat: Only compile-tested, and only on Linux)
Cheers
Anders
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [email protected]
From: Anders Larsen <[email protected]>
Date: Sun, 13 Jan 2013 16:02:00 +0100
Subject: [PATCH] Don't #include <libusb.h> from ftdi.h
Libusb is used internally but (normally) not needed by an application
directly, so don't include <libusb.h> from the exposed interface header.
Signed-off-by: Anders Larsen <[email protected]>
---
ftdipp/ftdi.cpp | 1 +
libftdi1.pc.in | 6 ++----
src/ftdi.h | 3 ++-
src/ftdi_stream.c | 1 +
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/ftdipp/ftdi.cpp b/ftdipp/ftdi.cpp
index 167325a..0382fa4 100644
--- a/ftdipp/ftdi.cpp
+++ b/ftdipp/ftdi.cpp
@@ -26,6 +26,7 @@ in accordance with section (3) of the GNU General Public License.
This exception does not invalidate any other reasons why a work based
on this file might be covered by the GNU General Public License.
*/
+#include <libusb.h>
#include "ftdi.hpp"
#include "ftdi_i.h"
#include "ftdi.h"
diff --git a/libftdi1.pc.in b/libftdi1.pc.in
index 300f38c..13f616c 100644
--- a/libftdi1.pc.in
+++ b/libftdi1.pc.in
@@ -2,12 +2,10 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
-libusb_libs=@LIBUSB_1_0_LIBS@
-libusb_cflags=@LIBUSB_1_0_CFLAGS@
Name: libftdi1
Description: Library to program and control the FTDI USB controller
Requires: libusb-1.0
Version: @VERSION@
-Libs: -L${libdir} -lftdi1 ${libusb_libs}
-Cflags: -I${includedir} ${libusb_cflags}
+Libs: -L${libdir} -lftdi1
+Cflags: -I${includedir}
diff --git a/src/ftdi.h b/src/ftdi.h
index 0348eea..141a795 100644
--- a/src/ftdi.h
+++ b/src/ftdi.h
@@ -17,7 +17,8 @@
#ifndef __libftdi_h__
#define __libftdi_h__
-#include <libusb.h>
+#include <stdint.h>
+#include <sys/time.h>
/** FTDI chip type */
enum ftdi_chip_type { TYPE_AM=0, TYPE_BM=1, TYPE_2232C=2, TYPE_R=3, TYPE_2232H=4, TYPE_4232H=5, TYPE_232H=6 };
diff --git a/src/ftdi_stream.c b/src/ftdi_stream.c
index 7a8c140..cf3acf5 100644
--- a/src/ftdi_stream.c
+++ b/src/ftdi_stream.c
@@ -41,6 +41,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <libusb.h>
#include "ftdi.h"
--
1.7.0.4