Skip to content

Dangerous #define clause #454

Description

@armallen

Hi,

I am currently using RTKLIB in a C++ multithreaded program.

The following code in rtklib.h conflicts with any other code using std::mutex

#define lock(f)     pthread_mutex_lock(f)
#define unlock(f)   pthread_mutex_unlock(f)

Here is a sample code showing the problem:

#include "rtklib.h"
#include <mutex>
using namespace std;

int main() {

    std::mutex m;
    m.lock();
    m.unlock();

    // Some rtklib code...

    return (0);
}

Compiling with g++ 4.8.5 causes the following error:

In file included from ../src/mutexLock.cpp:2:0:
/usr/include/c++/4.8.2/mutex:708:44: error: macro "lock" passed 3 arguments, but takes just 1
     lock(_L1& __l1, _L2& __l2, _L3&... __l3)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions