我有一个地图,将一对两个类映射到一个简单的字符串."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());
有什么建议?
我有问题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) 我正在尝试使用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 _> …
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?
我正在尝试为具有特定结尾的所有文件调用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) 我想写一个简单的函数,看看这个词是否通过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),我找不到.
许多人遇到了这个问题,但是提出的解决方案并没有帮助我。
在我的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
为什么我会收到此错误消息,如何消除它?
当打印包含反斜杠的字符串时,我希望反斜杠 ( \) 保持不变。
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!”。我怎样才能做到这一点?
如何将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)
这不起作用,那么如何将向量转换为字符串?
我有两个设计:
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.
有谁能解释为什么?
这个问题提出了很多次,没有一个给我正确的答案.
$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.我是否必须将其转换为数据库格式?或者我如何更改数据库中的格式?
在ModelSim中,您可以使用类似的东西
在modelsim中我们可以使用init_signal_spy("../.../ sig",mysignal);
获得深层次的信号.有没有办法通过Cadence的NCVhdl获得这样的信号?
这应该标记为"SimVision",这是工具的名称,但该标志似乎不存在.
我的测试平台使用在modelsim包(init_signal_spy)中定义的函数.所以我不能将这个测试平台用于与ModelSims vsim不同的模拟器,例如Candence的ncsim.但是在cadence包中有一个与ncsim(nc_mirror)等效的函数.解决方案是我需要有两个不同的测试平台.
但我只想使用一个.一种解决方案可能是,仅在设置了某个常量时才定义包.但我不知道这是否可行.