Home > Mobile >  Modules naming conflict
Modules naming conflict

Time:12-24

Is there anyway to use exported class/function without importing a module? Consider this example:

System.ixx

export module System;

export class String {...};

System2.ixx

export module System2;

export class String {...};

Is there anyway to use it like System::String or System2::String? Obviously when I import both modules I get a compiler error.

CodePudding user response:

Modules change how you access code from multiple files, but that's all they do. They do not (for the most part) affect the fundamental nature of C as a language.

C already has a tool for managing name conflicts between disparate libraries and source locations: namespaces. As such, C modules have no need to solve a problem that has adequately already been resolved.

  • Related