小编mah*_*ood的帖子

VHDL 中的 NULL 语句

nullVHDL中语句的实际目的是什么?考虑以下代码

1-

CASE s IS
BEGIN
     WHEN 0 =>    y <= 0;
     WHEN 1 =>    NULL;
END CASE;
Run Code Online (Sandbox Code Playgroud)

2-

CASE s IS
BEGIN
     WHEN 0 =>    y <= 0;
END CASE;
Run Code Online (Sandbox Code Playgroud)

在第二个代码中,由于 when 没有赋值s=1,则y保留它以前的值。不是吗?所以,我认为在这两种情况下,合成器都会放置一个触发器来保持y.

null vhdl

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

无法找到 perl 的模块/Build.pm

我不是 perl 专家(请参阅此页面),但是为了使用包,我必须运行一些 perl 命令。该命令显示此错误

$ perl Build.PL
Can't locate Module/Build.pm in @INC (@INC contains: /home/mahmood/src/bioperl-1.6.1 /home/mahmood/src/ensembl/modules 
/home/mahmood/src/ensembl-compara/modules /home/mahmood/src/ensembl-variation/modules 
/home/mahmood/src/ensembl-funcgen/modules /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl 
/usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Build.PL line 20.
BEGIN failed--compilation aborted at Build.PL line 20.
Run Code Online (Sandbox Code Playgroud)

我看到此回复提供cpan Module::Build先运行以修复该错误。当我运行该命令时,我看到一堆问题(文本向导),它们询问我一个镜像 url。然后它以交互方式询问我安装软件包的许可。问题的默认答案似乎具有这种效果。我也没有找到哪个问题对此负责。请查看pastebin的完整输出。

有什么方法可以自动安装模块,以便我可以将其放入脚本中以备将来使用。

更新:

似乎我必须输入 cpan.org 网址,但是在我之前的尝试中,我使用了镜像网站。我尝试了回复中提出的三个命令,但仍然出现相同的错误:

Please enter the URL of your CPAN mirror  http://www.cpan.org
Configuration does not allow connecting to the internet.
Current set of CPAN URLs:
  http://www.cpan.org
Enter another URL …
Run Code Online (Sandbox Code Playgroud)

perl

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

BufferedReader 正确使用

我使用以下样式使用 BufferedReader 读取文件

try (BufferedReader br = new BufferedReader(new FileReader("my_file"))) {
  ...
  br.close();
} catch( IOException e ) {
  System.out.println( e.getMessage() );
} 
Run Code Online (Sandbox Code Playgroud)

我想知道的事情:

1-close()在正确的地方吗?

2- 我应该try..catch为`close()放置另一个吗?

3- 因为我使用了newfor br,是否足以调用close()或者我必须br = null为 GC编写?

4-FileReader已经被new编辑了,所以我应该销毁它吗?

java bufferedreader

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

在C++中按位和

我已经定义了这样的枚举:

enum blStatus {
   Class1 = 0x40,           /* 0000,0100,0000 */
   Class2 = 0x80,           /* 0000,1000,0000 */
   Class3 = 0x100,          /* 0001,0000,0000 */
   Class4 = 0x200           /* 0010,0000,0000 */
}
Run Code Online (Sandbox Code Playgroud)

现在,在我的代码中的某个地方:

 if ( status &= Class1 )
   ++c1;
 else if ( status &= Class2 )
   ++c2;
 else if ( status &= Class3 )
   ++c3;
 else if ( status &= Class4 )
   ++c4;
Run Code Online (Sandbox Code Playgroud)

假设,状态为此值:

 status = 143   /* 0000,1000,1111 */
Run Code Online (Sandbox Code Playgroud)

在调试时,没有任何条件成立.但是"status&= Class2"是:

 0000,1000,1111 & 0000,1000,0000 = 0000,1000,0000
Run Code Online (Sandbox Code Playgroud)

并且c2计数器必须递增.但在调试时,所有条件都被传递(忽略)并且没有计数器增量.为什么?

c++ bitwise-operators

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

为枚举结构设置多个属性

我已经定义了enum这样的结构

class myC {
  enum accessClass {
    none,
    forL,
    forM,
    forA
  };

  typedef accessClass AccessType;
  AccessType aType;
};

myC obj;
Run Code Online (Sandbox Code Playgroud)

问题是我必须只选择一个成员.但是我想选择多个成员.目前如果我写

obj->aType = forL;
obj->aType = forM;
Run Code Online (Sandbox Code Playgroud)

然后后者将取代第一个.

我想为结构选择多个项目/成员/属性enum.

我该怎么办?

c++ enums attributes

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

将输出重定向到压缩格式(C)

是否可以以fprintf将数据写入压缩文件的方式使用?例如:

fopen ("myfile.txt","w");
Run Code Online (Sandbox Code Playgroud)

将写入纯文本文件.因此文件大小变得非常大.

c printf data-compression

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

用SED替换字符串

在一个文件(.py文件)中,我有一些不同名称的类,但有些具有公共变量:

class myClass1:
  f1 = '512kB'
  f2 = 2
  f3 = 'something1'

class myClass2:
  f1 = '512kB'
  f2 = 6
  f3 = 'something2'
Run Code Online (Sandbox Code Playgroud)

我想编写一个bash脚本并使用SED替换一些字符串.问题是我想首先找到myClass2然后替换f1 = '512kB'f1 = '1MB'

如果我使用

sed -i 's/f1 = '512kB'/f1 = '1MB'/g' /path/to/file
Run Code Online (Sandbox Code Playgroud)

它将替换两个类的字符串.

python bash sed

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

hg commit打开一个编辑器

当我运行时hg commit,vim编辑器打开并显示

HG: Enter commit message.  Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
Run Code Online (Sandbox Code Playgroud)

并显示一些路径.那是什么意思?你下一步怎么做?

mercurial

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

pthread 中函数的参数数量

在 pthread 的 hello world 示例中指出:

#include <pthread.h>
#include <stdio.h>

void * print_hello(void *arg)
{
  printf("Hello world!\n");
  return NULL;
}

int main(int argc, char **argv)
{
  pthread_t thr;
  if(pthread_create(&thr, NULL, &print_hello, NULL))
  {
    printf("Could not create thread\n");
    return -1;
  }

  if(pthread_join(thr, NULL))
  {
    printf("Could not join thread\n");
    return -1;
  }
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到print_hellopthread_create(),没有参数,但是在定义中,它看起来像void * print_hello(void *arg)

这意味着什么?

现在假设我有这个实现

void * print_hello(int a, void *);
int main(int argc, char **argv)
{
  pthread_t thr;
  int a …
Run Code Online (Sandbox Code Playgroud)

c pthreads

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

在csh中使用foreach语法

对于这个csh脚本

#!/bin/csh

foreach file in (.)
  echo "$file"
end
Run Code Online (Sandbox Code Playgroud)

我收到这个错误

foreach: Words not parenthesized.
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

linux shell csh

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