I stumbled upon the image processing libraries from https://github.com/nothings/stb/ and as I experiment with C++ modules I tried to use stb_image.h "as module".
For this I wrote a small wrapper module (same technique as demonstrated by glm, https://github.com/g-truc/glm which provide a wrapping of their library as C++ module inside glm.cppm) and it seems to work like a charm:
module;
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
export module stb_image;
// this "seems" correct
export using ::stbi_uc;
// this should be correct
export stbi_uc *stbi_load(char const *filename,int *x,int *y,int *comp,int req_comp);
export void stbi_image_free(void *retval_from_stbi_load);
// is this the correct way to export enum values?
export using ::STBI_default;
export using ::STBI_grey;
export using ::STBI_rgb;
export using ::STBI_rgb_alpha;
Where I am not sure at all is how to deal with these STBI values which are provided in stb_image.h as an unnamed enum:
enum
{
STBI_default = 0, // only used for desired_channels
STBI_grey = 1,
STBI_grey_alpha = 2,
STBI_rgb = 3,
STBI_rgb_alpha = 4
};
I experimented above and at least Visual C++ 2022 "accepts" what I came up with and the code executes correctly, the values can be used from other code importing this module "stbi_image".
But searching through the internet I could not really find any description of "if at all and how" such enum values from an unnamed enum can be exported in a C++ module.
Is what I did the correct way to do that?