Thread: How am I gonna create modules if they depend on each other?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2021
    Posts
    138

    How am I gonna create modules if they depend on each other?

    Rant (sorry I'm angry not because of the modules thing): Ok so first of all someone please tell me why the ........ they can't make a simple module system that works like any other ........ing language and they have to make this complicated and stupid MESS???

    Actual post:
    Ok so I have the following files:
    Code:
    // Filename: main.cc
    export module main;
    
    import second;
    import third;
    
    int main() { 
      second_fn();
      return 0;
    }
    Code:
    // Filename: second.cc
    export module second;
    
    import third;
    
    export void second_fn() {
      third_fn();
    }
    Code:
    // Filename: third.cc
    export module third;
    
    import second;
    
    #include   <stdio.h>
    
    export void third_fn() {
      printf("A message!\n");
    }
    I have read a lot of post (including the official docs from the LLVM) but nothing worked for me. Let's say that I try to compile "main.cc". I can use something like the following command:

    Code:
    clang-12 -std=c++2a -fimplicit-modules -fimplicit-module-maps -c main.cc -Xclang -emit-module-interface -o main.pcm
    But I will get the following error:

    Code:
    main.cc:3:8: fatal error: module 'second' not found
    import second;
    ~~~~~~~^~~~~~
    1 error generated.
    Ok so the module "second" must first get created. So let's first compile this file using the same command but changing the filename. Then I get this error:

    Code:
    
    second.cc:3:8: fatal error: module 'third' not found
    import third;
    ~~~~~~~^~~~~
    1 error generated.
    *STARTING TO GET ANGRY* Ok.... so let's first compile "third.cc".....

    Code:
    third.cc:3:8: fatal error: module 'second' not found
    import second;
    ~~~~~~~^~~~~~
    1 error generated.
    *THROWS COMPUTER OF THE WINDOW*

    I'm interested about GCC and Clang. Please help it's the only problem I'm having with C++ and I don't want to go on the D side because there are other problems here too....
    Last edited by rempas; 12-15-2021 at 01:51 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I make one project in VS depend on another
    By indigo0086 in forum Tech Board
    Replies: 19
    Last Post: 05-26-2009, 06:10 AM
  2. Create program that accept modules
    By rluceac in forum C++ Programming
    Replies: 16
    Last Post: 04-11-2009, 03:11 PM
  3. Is what I think is gonna happen gonna happen
    By cunnus88 in forum C++ Programming
    Replies: 2
    Last Post: 02-04-2009, 10:34 PM
  4. Complicated member objects that depend on `this`
    By drrngrvy in forum C++ Programming
    Replies: 3
    Last Post: 11-12-2006, 09:48 PM
  5. Anyone else had this e mail ??? ooh i'm gonna be rich !!
    By stevey in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 04-11-2002, 11:12 AM

Tags for this Thread