phoboslab / pl_mpeg

Single file C library for decoding MPEG1 Video and MP2 Audio
799 stars 58 forks source link

Modify public struct typedefs to enable fwd declaration in C++ #6

Open tomasandrle opened 5 years ago

tomasandrle commented 5 years ago

It would be helpful to change

typedef struct {
...
} plm_frame_t;

into

typedef struct plm_frame_t {
...
} plm_frame_t;

This would make it easier to forward-declare the structs in a C++ header without including pl_mpeg.h from there, exposing it to the rest of the program.

Example my.hpp:

struct plm_frame_t; // trying to not include pl_mpeg.h here

class MyClass {
public:
    void render( plm_frame_t *frame );
};

Example my.cpp:

#include "my.hpp"
#define PL_MPEG_IMPLEMENTATION
#include "pl_mpeg.h"

MyClass::render( plm_frame_t *frame ) {
...
}