小编Sad*_*dik的帖子

错误:无法匹配'(const std :: basic_string <char>)()'

我有一个地图,将一对两个类映射到一个简单的字符串."FirstCollection"和"SecondCollection"是类,"myCollecttion"是其中之一的对象.但是当迭代地图时,我收到编译错误:

错误:调用'(const std :: basic_string)()'不匹配

typedef std::map <
    std::pair < Collection, Envelope::Envelope >
  , std::string > NameMap;

NameMap globalNameMap = map_list_of
        ( std::make_pair ( FirstCollection, Envelope::A ), "Something")
        ( std::make_pair ( SecondCollection, Envelope::B ), "Another thing")


    NameMap::const_iterator iter
            = globalNameMap.find( std::make_pair ( myCollection, myEnvelope ));

    if ( iter == globalNameMap.end() )
    {
          parent->setName("anything");
    } else {
          parent->setName(iter->second());
    }
Run Code Online (Sandbox Code Playgroud)

这行错误: parent->setName(iter->second());

有什么建议?

c++ map stdstring c++11

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

c ++链接ubuntu下的boost库和cmake:未定义引用`boost :: iostreams :: zlib :: okay'

我有问题boost::iostreams.我想只在一个函数中使用它们.唯一的问题是这一行:

in.push(boost::iostreams::gzip_decompressor());
Run Code Online (Sandbox Code Playgroud)

Boost用于程序的其他部分,没有任何问题或编译错误.但是,如果我使用这一行,我得到编译错误:

undefined reference to `boost::iostreams::zlib::okay'
Run Code Online (Sandbox Code Playgroud)

它包括这样:

#include <boost/iostreams/filter/gzip.hpp>
Run Code Online (Sandbox Code Playgroud)

的CMakeLists.txt

add_library(backend
    ... some files
)

find_package(Boost COMPONENTS system REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(backend ${Boost_LIBRARIES})
Run Code Online (Sandbox Code Playgroud)

c++ boost gzip cmake

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

使用CMake设置SystemC项目:未定义引用`sc_core

我正在尝试使用CMake在SystemC中构建一个简单的hello世界.

这是SystemC文件main.cpp:

#include <systemc.h>

using namespace std;

SC_MODULE (hello_world) {
  SC_CTOR (hello_world) {
  }

  void say_hello() {
    cout << "Hello World SystemC" << endl;
  }
};

int sc_main(int argc, char* argv[]) {
  hello_world hello("HELLO");
  hello.say_hello();
  return(0);
}
Run Code Online (Sandbox Code Playgroud)

这是CMakeLists.txt:

cmake_minimum_required(VERSION 3.1)
project(SystemCExample)

set (CMAKE_PREFIX_PATH /usr/local/systemc-2.3.2)

include_directories(${CMAKE_PREFIX_PATH}/include)

find_library(systemc systemc ${CMAKE_PREFIX_PATH}/lib-linux64)
link_directories(${CMAKE_PREFIX_PATH}/lib-linux64)

set(CMAKE_CXX_STANDARD 11) # C++11...

set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...

set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11

aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})

target_link_libraries(SystemCExample systemc)
Run Code Online (Sandbox Code Playgroud)

我一直收到错误:

/usr/local/systemc-2.3.2/include/sysc/kernel/sc_ver.h:179:错误:未定义引用`sc_core :: sc_api_version_2_3_2_cxx201103L <&sc_core :: SC_DISABLE_VIRTUAL_BIND_UNDEFINED _> …

cmake systemc

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

Why can I implicitly convert char* to const char* but not unsigned char*

The following code snippet produces a compile error:

char a = 'a';
const char* a_ = &a;
unsigned char b = 'b';
const char* b_ = &b;
Run Code Online (Sandbox Code Playgroud)

The last line produces the error:

error: invalid conversion from 'unsigned char*' to 'const char*'
Run Code Online (Sandbox Code Playgroud)

I can implicitly convert from char* to const char*, but I cannot do the same for unsigned char*? What is the reason behind this?

c++

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

CMake警告:您已为库my_src调用ADD_LIBRARY而没有任何源文件

我正在尝试为具有特定结尾的所有文件调用add_library.

dir结构是:

src 
 | - CMakeLists.txt (1)
 | - main.cpp
 | - gui
      | - CMakeLists.txt (2)
      | - some source and header files
Run Code Online (Sandbox Code Playgroud)

所以目前所有cc文件都在gui目录中.

(1)CMakeLists.txt:

file( GLOB_RECURSE my_sources *.cc ) 
message(STATUS "my_sources = ${my_sources}")
add_subdirectory( gui )
add_library( my_src ${my_SOURCES} )

target_link_libraries( my_src
  my_gui
)
qt5_use_modules( my_src Core Gui Widgets)
Run Code Online (Sandbox Code Playgroud)

(2)CMakeLists.txt:

file( GLOB my_gui_sources *.cc)

add_library( my_gui ${my_gui_sources} )
qt5_use_modules( my_gui Core Gui Widgets)
Run Code Online (Sandbox Code Playgroud)

但我一直得到这个输出:

You have called ADD_LIBRARY for library my_src without any source files. This typically indicates …
Run Code Online (Sandbox Code Playgroud)

cmake qt-creator qt5

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

为什么NLTK WordNet找不到简单的单词?

我想写一个简单的函数,看看这个词是否通过NLTK在WordNet中"存在".

def is_known(word):
    """return True if this word "exists" in WordNet
       (or at least in nltk.corpus.stopwords)."""
    if word.lower() in nltk.corpus.stopwords.words('english'):
        return True
    synset = wn.synsets(word)
    if len(synset) == 0:
        return False
    else:
        return True
Run Code Online (Sandbox Code Playgroud)

为什么会这样的话会could, since, without, although返回False?它们不会出现在WordNet中吗?有没有更好的方法来确定WN中是否存在单词(使用NLTK)?

我的第一个尝试是消除"停止词",这些词是类似的to, if, when, then, I, you,但仍然有很常见的词(比如could),我找不到.

python nltk wordnet

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

UnicodeEncodeError仅在通过管道传输到文件时,并且仅在某些PC上时

许多人遇到了这个问题,但是提出的解决方案并没有帮助我。

在我的ubuntu机器上,脚本运行无错误。但是在我的raspi上,不断出现此错误:

UnicodeEncodeError: 'ascii' codec can't encode character '\xd6' in position 21: ordinal not in range(128)
Run Code Online (Sandbox Code Playgroud)

错误提示德语字符(umlaut,ö),应使用 print(a_name)

令我感到困惑的是:打电话时,python3 myscript.py我在raspi上没有任何错误。但是通过电话python3 myscript.py> output我得到了错误。与nohup python3 myscript.pycrontab 相同或从crontab运行时:

@reboot LANG=de_DE.UTF-8 /home/pi/launcher.sh > /home/pi/bot/logs/cronlog 2>&1
Run Code Online (Sandbox Code Playgroud)

其中launcher.sh使用以下代码:

python3 myscript.py > pythonlog 2>&1
Run Code Online (Sandbox Code Playgroud)

我检查了$ LANG

在我的ubuntu电脑上(没有任何错误):en_US.UTF-8

在raspi上:de_DE.UTF-8

为什么我会收到此错误消息,如何消除它?

python unicode utf-8

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

字符串中的反斜杠

当打印包含反斜杠的字符串时,我希望反斜杠 ( \) 保持不变。

test1 = "This is a \ test String?"
print(test1)
'This is a \\ test String?'

test2 = "This is a '\' test String?"
print(test2)
"This is a '' test String?"
Run Code Online (Sandbox Code Playgroud)

我期望的分别是“ This is a \ test String!”或“ This is a '\' test String!”。我怎样才能做到这一点?

python

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

vhdl:将向量转换为字符串

如何将std_logic向量,bit_vector或任何其他向量转换为字符串?

Signal a,b          : UNSIGNED(7 DOWNTO 0);
SIGNAL x,y,z    : BIT_VECTOR(7 DOWNTO 0);

...

report "value: " & BIT_VECTOR'Image(x) severity note;
report "and this one: " & to_string(a) severity note;
Run Code Online (Sandbox Code Playgroud)

这不起作用,那么如何将向量转换为字符串?

arrays string vector type-conversion vhdl

0
推荐指数
3
解决办法
2万
查看次数

VHDL等于运算符:std_logic和std_ulogic的不同行为

我有两个设计:

library ieee;
use ieee.std_logic_1164.all;

entity eq_test1 is

  port (a,b : IN std_logic_vector (1 downto 0);
        o   : OUT std_logic); 
end eq_test1;

architecture strange_behavior of eq_test1 is
begin  
    P: process (a,b)
    begin
        if a = b then o <= '1';
        else o <= '0';
        end if;
    end process P;
end strange_behavior;
Run Code Online (Sandbox Code Playgroud)

强制在Modelsim中具有"00"并且b具有"0L"表示o变为"0".因此L不被解释为0,"00"="0L"为假.好.

但是当我采用相同的设计并添加时

use ieee.std_logic_unsigned.all;
Run Code Online (Sandbox Code Playgroud)

到列表中,行为是不同的.然后"00"="0L"返回true,因此L IS与0相同(0变为"1").包含未签名的包,即使"0X"="0Z"也返回true.

有谁能解释为什么?

behavior vhdl modelsim

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

用正确的格式将日期插入mysql插入'0000-00-00'

这个问题提出了很多次,没有一个给我正确的答案.

$birthday=date('d.m.Y', strtotime($_POST['birthday']));
echo "birthday: ".$birthday // prints "15.05.1998" - that's nice    
$query = "INSERT INTO teilnehmer (vorname, nachname, email, geschlecht, birthday, telefon) VALUES ('$vorname', '$nachname', '$email', '$geschlecht', '$birthday', '$telefon')";
$erfolg = mysql_query($query, $verbindungID) or die ("Beim Erstellen ist ein Fehler unterlaufen. ". mysql_error());
Run Code Online (Sandbox Code Playgroud)

数据库条目显示0000-00-00.我是否必须将其转换为数据库格式?或者我如何更改数据库中的格式?

php mysql sql format date

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

在ncvhdl中获取vhdl设计的内部信号(替代modelsim的信号间谍)

在ModelSim中,您可以使用类似的东西

在modelsim中我们可以使用init_signal_spy("../.../ sig",mysignal);

获得深层次的信号.有没有办法通过Cadence的NCVhdl获得这样的信号?

这应该标记为"SimVision",这是工具的名称,但该标志似乎不存在.

vhdl modelsim cadence

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

如果两个模拟器都需要使用自己的软件包,有没有办法将一个测试平台用于不同的模拟器?

我的测试平台使用在modelsim包(init_signal_spy)中定义的函数.所以我不能将这个测试平台用于与ModelSims vsim不同的模拟器,例如Candence的ncsim.但是在cadence包中有一个与ncsim(nc_mirror)等效的函数.解决方案是我需要有两个不同的测试平台.

但我只想使用一个.一种解决方案可能是,仅在设置了某个常量时才定义包.但我不知道这是否可行.

vhdl modelsim cadence

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