[libcamera-devel] [PATCH] lib: Fix class and namespace usage

Kieran Bingham kieran.bingham at ideasonboard.com
Fri Nov 30 12:07:37 CET 2018


The (dummy) init_lib function was linking correctly only due to a
namespace 'collision' adding the init_lib to libcamera namespace, which
is 'shared' by class libcamera.

The init function was designed to be a class member function of the
libcamera object - and is used as such in the existing test function.

Instead of relying on the namespace collision - update the lib/main.cpp
example file to correctly utilise the class header - and specify the
function declaration, so that further implementations do not fall into
the same bad habits.

Reported-by: Jacopo Mondi <jacopo at mondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
 lib/main.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lib/main.cpp b/lib/main.cpp
index 7b3da269f695..37f1ccce43cc 100644
--- a/lib/main.cpp
+++ b/lib/main.cpp
@@ -1,13 +1,10 @@
 #include <iostream>
-
-namespace libcamera {
+#include <libcamera/libcamera.h>
 
 using std::cout;
 using std::endl;
 
-void init_lib(void)
+void libcamera::init_lib(void)
 {
 	cout << "Lib Camera Init" << endl;
 }
-
-};
-- 
2.17.1



More information about the libcamera-devel mailing list