C-Macro-Collections icon indicating copy to clipboard operation
C-Macro-Collections copied to clipboard

Do not include code by default

Open duarm opened this issue 2 years ago • 0 comments
trafficstars

Thanks for working on C-Macro-Collections!

What is the nature of this request?

  • Change in standards

Is your feature request related to a problem? Please describe.

you can easily make a new list with

#define V struct my_struct
#define PFX my_struct
#define SNAME my_struct_list
#include <cmc/ds/list.h>

since cmc/ds/list.h includes the #include "cmc/list/code.h", you can't just place the above snippet on a header, because it would define each function multiple times.

In order to share declarations, you need to do something like this

file.c

#define V struct my_struct
#define PFX my_struct
#define SNAME my_struct_list
#include <ds/cmc/list/code.h>
#include <ds/cor/undef.h>

file.h

#define V struct my_struct
#define PFX my_struct
#define SNAME my_struct_list
#include <ds/cmc/list/struct.h>
#include <ds/cmc/list/header.h>
#include <ds/cor/undef.h>

Describe the solution you'd like

I think it would be much better if we could do this

file.c

#define V struct my_struct
#define PFX my_struct
#define SNAME my_struct_list
#include <ds/cmc/list/code.h>
// code includes undef.h

file.h

#define V struct my_struct
#define PFX my_struct
#define SNAME my_struct_list
#include <ds/cmc/list.h>

What do you think? It would be a breaking change, I can open a PR if you agree it's a good change.

Alternatves

Maybe this? I prefer the above file.c

#define V struct my_struct
#define PFX my_struct
#define SNAME my_struct_list
#define SOURCE
#include <ds/cmc/list.h>

file.h

#define V struct my_struct
#define PFX my_struct
#define SNAME my_struct_list
#include <ds/cmc/list.h>

duarm avatar Nov 02 '23 07:11 duarm