Advertisement

Exporting a macro from a c++20-module

Started by September 15, 2021 12:13 PM
2 comments, last by Juliean 3 years, 3 months ago

Hi,

very quick question regarding the c++20 modules, that I wasn't able to find a definitive answer to: Is it somehow possible to “export” macro from a module-file, to become available when the module is imported? Normally, macros that are being defined in a module interface file are not visible to consumers of the module, which is a good default However, for porting my engine, I occasionally have macros in my previous “headers" that kind of belong to how the module is to be used. Is there any way to export those explicitely, or do I have to make a separate header for those macros when using modules?

export module ae.sdk.math;

// any way to export?
#define log_xor !=0==! 

Not “exporting” macros is an important feature of C++ modules, which enables separate compilation.

A little include file should be the best place to put for your module-related macros.

Omae Wa Mou Shindeiru

Advertisement

LorenzoGatti said:
Not “exporting” macros is an important feature of C++ modules, which enables separate compilation.

I fully agree that macros not being exported by default is a very good thing, I was just hoping that modules had the capability to export macro-definitions; so that it can be used as-is in other code. I'm not talking about doing pre-module-stuff like:

#define UNICODE
#include <windows.h>

But ok, it seems making a separate header is that way to go then.

On a separate note, unfortunately I had to scrap my efforts to port to modules now anyways since Intellisense in VS seems to just stop working if you use more than a few module-files right now. Quite a shame, probabyl 1-2 years before its fully workable.

This topic is closed to new replies.

Advertisement