标签: glibc

是否允许 srand(0) 具有与 srand(1) 相同的效果?

是否允许srand(0)具有与 相同的效果srand(1)

C11,7.22.2.2 srand 函数(添加强调):

srand 函数使用参数作为后续调用 rand 返回的新伪随机数序列的种子。

然而,在 glibc 中srand(0)具有相同的效果srand(1)

  /* We must make sure the seed is not 0.  Take arbitrarily 1 in this case.  */
  if (seed == 0)
    seed = 1;
Run Code Online (Sandbox Code Playgroud)

因此,后续调用会返回相同的伪随机数序列rand,这令人困惑。

额外:我们​​看到在 MSVC 中srand(0)并没有与srand(1).

c random glibc srand language-lawyer

2
推荐指数
1
解决办法
133
查看次数

当我在 centos 7.5 上使用 make 命令编译 glibc-2.28 时,出现类似参数 1 of type 'struct __jmp_buf_tag *' statements 一样的错误,声明为指针

步骤是:

\n
    \n
  1. 更新make版本到4.8
  2. \n
  3. 更新gcc版本到12.2.0
  4. \n
  5. 执行以下步骤编译glibc\xef\xbc\x9a
  6. \n
\n
tar zxf glibc-2.28.tar.gz && cd glibc-2.28\nmkdir build && cd build\n\n../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin\n\nmake -j 8\n\n
Run Code Online (Sandbox Code Playgroud)\n

我得到如下:

\n
inux-gnu/12.2.0/include-fixed -isystem /usr/include -D_LIBC_REENTRANT -include /root/source/glibc-2.28/build/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h       -DTOP_NAMESPACE=glibc \\\n        -DGEN_AS_CONST_HEADERS -x c - \\\n        -MD -MP -MF /root/source/glibc-2.28/build/tcb-offsets.h.dT -MT '/root/source/glibc-2.28/build/tcb-offsets.h.d /root/source/glibc-2.28/build/tcb-offsets.h'\nIn file included from ../include/pthread.h:1,\n                 from ../nptl/../nptl_db/thread_db.h:25,\n                 from ../nptl/descr.h:32,\n                 from ../sysdeps/x86_64/nptl/tls.h:130,\n                 from ../sysdeps/unix/sysv/linux/x86_64/sysdep.h:24,\n                 from <stdin>:1:\n../sysdeps/nptl/pthread.h:744:47: error: argument 1 of type 'struct __jmp_buf_tag *' declared as a pointer [-Werror=array-parameter=]\n …
Run Code Online (Sandbox Code Playgroud)

glibc centos

2
推荐指数
1
解决办法
2783
查看次数

glibc中重复内存分配的效率

下面是来自着名的LAPACK数值库的Fortran ZHEEVR例程的C包装器:

void zheevr(char jobz, char range, char uplo, int n, doublecomplex* a, int lda, double vl, double vu, int il, int iu, double abstol, double* w, doublecomplex* z, int ldz, int* info)
{
    int m;
    int lwork = -1;
    int liwork = -1;
    int lrwork = -1;
    int* isuppz = alloc_memory(sizeof(int) * 2 * n);
    zheevr_(&jobz, &range, &uplo, &n, a, &lda, &vl, &vu, &il, &iu, &abstol, &m, w, z, &ldz, isuppz, small_work_doublecomplex, &lwork, small_work_double, &lrwork, small_work_int, &liwork, &info);
    lwork …
Run Code Online (Sandbox Code Playgroud)

c performance memory-management glibc

1
推荐指数
2
解决办法
733
查看次数

在glibc源中找到select()源代码的位置?

我试图在glibc源代码中找到select()源代码(linux,i386 arch),但我找不到任何东西(与所述架构有关)

有人能指出我的select()源代码吗?

c linux kernel glibc

1
推荐指数
1
解决办法
4212
查看次数

printf("%d",1.0)是否未定义?

根据C89草案第4.9.6.1节,%d是一个字符,用于指定要应用的转换类型.

在我看来,转换一词意味着printf("%d", 1.0)定义了.

请确认或反驳此事.

c printf glibc stdio libc

1
推荐指数
2
解决办法
311
查看次数

GCC - 标准库中的致命错误,包括

我正在编译一个包含一些标准库的代码作为new,cmath等......但是gcc不能包含它们.

我使用python3.2 distutils来构建它.

它给了我这个错误:gcc fatal error: cmath: No such file or directory.我google了一下,可能我的gcc配置不好,必须重新安装.

我试图在我的archlinux pc上重新安装glibc和gcc及其所有依赖项:sudo pacman -S --recursive glibc gcc但没有任何改变.

问题是什么?

c c++ gcc glibc archlinux

1
推荐指数
1
解决办法
3553
查看次数

哪里可以找到glibc中数学函数ceil()的源代码?

我已经下载了glibc的源代码,并且很长一段时间找到函数ceil(),但我找不到它,谁能告诉我它在哪里?

我在哪里可以找到有关如何在glibc源代码中找到某些函数源代码的详细信息.

谢谢.

c glibc ceil

1
推荐指数
1
解决办法
612
查看次数

Ubuntu编译的程序在Unix webserver上运行

我使用GNAT在Ubuntu上编译了一个Ada程序.

之后,我尝试了一些使用该程序的测试,并且它运行正常.

但是,当我将其上传到我的Apache(UNIX)网络服务器并尝试运行该程序时,没有输出.为什么会这样?

可能是在Ubuntu上编译的程序在UNIX服务器上不起作用吗?

(抱歉这个愚蠢的问题!)

我用于编译的系统的Linux版本(uname -a):

Linux ubuntu 3.0.0-12-generic #20-Ubuntu x86-64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

系统的Linux版本我想稍后运行该程序(uname -a):

Linux 2.6.37-he-xeon-64gb+1 i686 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

为了在Ubuntu机器上进行编译,我使用:

gnatmake -O3 myprogram -bargs -static
Run Code Online (Sandbox Code Playgroud)

apache ubuntu gcc glibc ada

1
推荐指数
1
解决办法
838
查看次数

glibc检测到双重免费或腐败

下面的代码有什么问题.对于某些输入和某些特殊输入的崩溃,它运行完全正常吗?

#include<iostream>
#include<string>
#include<fstream>

using namespace std;


struct event { 

string date,time,content;
bool is_high_priority;

};


int main() {

event one,two;
one.is_high_priority=false;
char tmp;

ofstream out_file("events" , ios::binary );


    cout<<"\nEnter Date(dd.mm) ";
    cin>>one.date;
    cout<<"\nEnter Time(hh:mm:ss) ";
    cin>>one.time;
    cout<<"\nenter content";
    cin>>one.content;

    if(tmp == 't') 
        one.is_high_priority = true;
    else
        one.is_high_priority = false;


    out_file.write((char*) &one, sizeof(one) );

    out_file.close();


    ifstream in_file("events" , ios::binary );
    in_file.read((char*)&two,sizeof(two));

    cout<<two.date<<" "<<two.time<<" "<<two.content<<" "<<two.is_high_priority;

    in_file.close();

}
Run Code Online (Sandbox Code Playgroud)

它为这些输入而崩溃:输入日期(dd.mm)ankmjjdn md

输入时间(hh:mm:ss)输入contentsnjs sjnsn

c++ crash glibc

1
推荐指数
1
解决办法
994
查看次数

在linux中,malloc给你的数据是什么?

当你在linux中使用malloc内存时,不能保证根据规范将其归零.那么你得到的数据呢?

linux malloc glibc

1
推荐指数
1
解决办法
148
查看次数