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

Laurent Pinchart laurent.pinchart at ideasonboard.com
Fri Nov 30 20:56:42 CET 2018


Hi Kieran,

Thank you for the patch.

On Friday, 30 November 2018 13:07:37 EET Kieran Bingham wrote:
> 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>

This looks good to me, feel free to merge with 

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

even if the code will go away very soon.

> ---
>  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;
>  }
> -
> -};

-- 
Regards,

Laurent Pinchart





More information about the libcamera-devel mailing list