News for hackers. Stuff that matters.
Re:Show HN: Cpp_Redis – C++11 Lightweight Redis client by hans0l074 on Tuesday July 04, 2017 @03:01AM (#14694072)
A few years ago, I dabbled with the idea of building a "shared clipboard" application across platforms and decided to use Redis - esply the pub/sub mechanism - for this. I ended up discovering and using hiredis[0] (which I can see now was co-authored by antirez as well). I'm curious to know if hiredis can be used from C++ 11 as well.

[0] https://github.com/redis/hiredis

Re:Show HN: Cpp_Redis – C++11 Lightweight Redis client by pjmlp on Tuesday July 04, 2017 @03:43AM (#14694239)
As arjo129 says, there is nothing preventing you from using hiredis, provided they don't make use of the few cases where C language features and C++ are no longer compatible, e.g. VLAs or structure initializers.

However, given it is a C API you will get the usual C unsafe code, instead of C++'s improvements regarding type safety.

Re:Show HN: Cpp_Redis – C++11 Lightweight Redis client by jjnoakes on Tuesday July 04, 2017 @09:43AM (#14695813)
> provided they don't make use of the few cases where C language features and C++ are no longer compatible, e.g. VLAs or structure initializers

Wouldn't one compile hiredis in C, their app in C++, and link the two together?

In general compiling C code with a C++ compiler isn't the path of least resistance.

Re:Show HN: Cpp_Redis – C++11 Lightweight Redis client by pjmlp on Tuesday July 04, 2017 @12:35PM (#14696795)
Depends how C++ compatible are the headers, as they can't make use of C99 or C11 features that aren't part of ANSI C++17.
Re:Show HN: Cpp_Redis – C++11 Lightweight Redis client by jjnoakes on Tuesday July 04, 2017 @01:14PM (#14697057)
True, although most C libraries ought to use those features in the implementation files and not the headers if they want to be used widely.

And even if some things leak into the headers they might be accepted by compiler extensions.

But yes, in general if a c library's headers are hostile to cross-language usage then using it from c++ won't be trivial.

Re:Show HN: Cpp_Redis – C++11 Lightweight Redis client by arjo129 on Tuesday July 04, 2017 @03:23AM (#14694161)
There's nothing stopping you from using hiredis in c++