[Bug 2039895] [NEW] module complie error
xwj
2039895 at bugs.launchpad.net
Fri Oct 20 01:34:23 UTC 2023
Public bug reported:
//num.ixx
module; //global module
//#incldue <> //lib not modularized
#include <bits/stdc++.h>
export module random:num;
//import //module
// //non-export declaration
export
{
inline int random_num(std::pair<int,int> range);
inline int random_num(std::pair<int,int> range,int seed);
}
inline int random_num(std::pair<int, int> range)
{
std::random_device rd; // 使用随机设备生成种子
std::mt19937 gen(rd()); // 使用Mersenne Twister引擎
std::uniform_int_distribution<int> dist(range.first , range.second); // 定义随机数范围
return dist(gen);
}
inline int random_num(std::pair<int, int> range, int seed)
{
std::mt19937 gen(seed); // 随机数引擎
std::uniform_int_distribution<int> dist(range.first , range.second); // 定义随机数范围
return dist(gen);
}
//random.ixx
module; //global module
//#incldue <> //lib not modularized
export module random;
//import //module
export import :num;
// //non-export declaration
export
{
void f()
{}
}
//complie way
MODULE_FLAGS=-g -std=c++20 -fmodules-ts -x c++ -c
g++ ${MODULE_FLAGS} num.ixx
g++ ${MODULE_FLAGS} random.ixx
//issue
1 . i dont know what happened since i add flag:-g
2 . before that , there still have issue :
when i import random to use the function random_num(range) , when i step : std::random_device rd;
a error occasion from bit/string.h? but i cant formally use random_device in header system project?
** Affects: gcc-11 (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-11 in Ubuntu.
https://bugs.launchpad.net/bugs/2039895
Title:
module complie error
Status in gcc-11 package in Ubuntu:
New
Bug description:
//num.ixx
module; //global module
//#incldue <> //lib not modularized
#include <bits/stdc++.h>
export module random:num;
//import //module
// //non-export declaration
export
{
inline int random_num(std::pair<int,int> range);
inline int random_num(std::pair<int,int> range,int seed);
}
inline int random_num(std::pair<int, int> range)
{
std::random_device rd; // 使用随机设备生成种子
std::mt19937 gen(rd()); // 使用Mersenne Twister引擎
std::uniform_int_distribution<int> dist(range.first , range.second); // 定义随机数范围
return dist(gen);
}
inline int random_num(std::pair<int, int> range, int seed)
{
std::mt19937 gen(seed); // 随机数引擎
std::uniform_int_distribution<int> dist(range.first , range.second); // 定义随机数范围
return dist(gen);
}
//random.ixx
module; //global module
//#incldue <> //lib not modularized
export module random;
//import //module
export import :num;
// //non-export declaration
export
{
void f()
{}
}
//complie way
MODULE_FLAGS=-g -std=c++20 -fmodules-ts -x c++ -c
g++ ${MODULE_FLAGS} num.ixx
g++ ${MODULE_FLAGS} random.ixx
//issue
1 . i dont know what happened since i add flag:-g
2 . before that , there still have issue :
when i import random to use the function random_num(range) , when i step : std::random_device rd;
a error occasion from bit/string.h? but i cant formally use random_device in header system project?
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-11/+bug/2039895/+subscriptions
More information about the foundations-bugs
mailing list