g++ (GCC) 4.7.2
3.7.6-201.fc18.x86_64 #1 SMP Mon Feb 4 15:54:08 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Fedora release 18 (Spherical Cow)
Run Code Online (Sandbox Code Playgroud)
你好,
我正在编译并尝试链接程序时遇到问题.
链接器错误是:
/usr/bin/ld: point.o: undefined reference to symbol '_Znwj@@GLIBCXX_3.4'
/usr/bin/ld: note: '_Znwj@@GLIBCXX_3.4' is defined in DSO /lib/libstdc++.so.6 so try adding it to the linker command line
/lib/libstdc++.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
该目标文件point.o试图调用libstdc ++中不存在的函数.
当我尝试使用readelf检查符号名称是否存在时,我无法找到它.
readelf --all libstdc++.so.6.0.17 | grep _Znwj@@GLIBCXX_3.4
Run Code Online (Sandbox Code Playgroud)
这是因为point.o正在寻找旧版libstdc ++中的符号,该符号可能在以后的版本中删除了吗?
非常感谢任何建议,
gcc (GCC) 4.7.2
cmake version 2.8.11
Run Code Online (Sandbox Code Playgroud)
你好,
我想知道是否有办法解决以下问题.我在下面突出显示:
SET(GW_SOURCE_FILES
module.c
module_imp.c
module_message.c
module_config.c
module_queue.c)
# Compiles the source files to create the shared library called dlg_gw.so
ADD_LIBRARY(dlg_gw SHARED ${GW_SOURCE_FILES})
# Link additional libraries to this
TARGET_LINK_LIBRARIES(dlg_gw gc srl ${APRUTIL})
# ISSUE: Now I want to create my executable using the same source files. module.c is where my 'void main(void)' is.
# However, I have some functions in there which will also be part of the library.
# However, this will …Run Code Online (Sandbox Code Playgroud) gcc (GCC) 4.7.2
c89
Run Code Online (Sandbox Code Playgroud)
我正在使用管道mkfifo.我有一个读者和一个作家.
我希望读者阻止,直到文件中有东西.
有一个标志可以设置O_NONBLOCK,用于非阻塞模式.因此默认情况下它应该阻止读取.
写入文件
int main(void)
{
int fd;
const char *pipe_file = "../../pipe_file/file";
const char *pipe_msg = "PIPE Message";
LOG_INFO("Start writer");
/* Create the FIFO named pipe with read/write permissions */
mkfifo(pipe_file, 0666);
/* Write to the pipe */
fd = open(pipe_file, O_WRONLY);
write(fd, pipe_msg, strlen(pipe_msg) + 1);
LOG_INFO("Terminate writer");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
从文件中读取
int main(void)
{
int fd = -1;
const char *pipe_file = "../../pipe_file/file";
#define BUF_SIZE 1024
char rd_buffer[BUF_SIZE];
LOG_INFO("Start reader");
fd = …Run Code Online (Sandbox Code Playgroud) 我的公司刚刚开始开发将在Android智能手机上运行的Android应用程序.
是否最好在最流行的智能手机上测试,即Galaxy S4?或者在任何廉价的中国智能手机上进行测试都一样好吗?
我们可以购买S4,但不能购买所有智能设备.但是,我们会尽可能地降低预算.
由于每个智能设备上的硬件规格不同,我们希望确保它适用于最受欢迎的设备.
非常感谢任何建议,
Android Studio 2.1.2
如果用户点击按钮并且用户名为空,我试图让测试失败.这是我的代码.但是,测试总是通过.有没有办法进行测试,如果它EditText是空的,它将失败.
@Test
public void shouldFailToLoginWithEmptyUserName() {
onView(withId(R.id.btnSignIn)).perform(ViewActions.click());
onView(withId(R.id.etUsername)).check(ViewAssertions.matches(withText("")));
}
Run Code Online (Sandbox Code Playgroud) Android Studio 2.2.2
Run Code Online (Sandbox Code Playgroud)
我有一个NewsListModelImp类,它是MVP中的模型.
我想将改装服务注入模型中.但是,因为NewsListModelImp不包含对我无法调用的上下文或活动的任何引用getApplication().如果您在活动或片段中,您将采取以下措施.我不想在构造函数中传递任何上下文或活动,NewsListModeImp因为它必须来自演示者,我想避免任何android的东西.
public class NewsListModelImp implements NewsListModelContract {
@Inject
NYTimesSearchService mNYTimesSearchService;
public NewsListModelImp() {
((NYTimesSearchApplication)getApplication()).getAppComponent().inject(this);
}
}
Run Code Online (Sandbox Code Playgroud)
我的应用程序类
public class NYTimesSearchApplication extends Application {
private AppComponent mAppComponent;
public void onCreate() {
super.onCreate();
/* Setup dependency injection */
createAppComponent();
}
private void createAppComponent() {
mAppComponent = DaggerAppComponent
.builder()
.retrofitModule(new RetrofitModule())
.build();
}
public AppComponent getAppComponent() {
return mAppComponent;
}
}
Run Code Online (Sandbox Code Playgroud)
我提供的模块
@Module
public class RetrofitModule {
private Retrofit retrofit() { …Run Code Online (Sandbox Code Playgroud) io.reactivex.rxjava2:rxjava:2.1.13
kotlin_version = '1.2.30'
Run Code Online (Sandbox Code Playgroud)
我具有以下Observable,并且尝试引发异常以测试OnError中异常的捕获。但是,当我将以下内容传递给时,将onExceptionResumeNext(Observable.just(10))得到以下输出:
1
2
10
onComplete
fun main(args: Array<String>) {
Observable.fromArray(1, 2, 0, 4, 5, 6)
.doOnNext {
if (it == 0) {
throw RuntimeException("Exception on 0")
}
}
.onExceptionResumeNext(Observable.just(10))
.subscribe(
{
println(it)
},
{
println("onError ${it.message}")
},
{
println("onComplete")
} )
}
Run Code Online (Sandbox Code Playgroud)
但是,如果将lambda表达式传递给该方法,则会得到以下输出:
1
2
Observable.fromArray(1, 2, 0, 4, 5, 6)
.doOnNext {
if (it == 0) {
throw RuntimeException("Exception on 0")
}
}
.onExceptionResumeNext { Observable.just(10) }
.subscribe(
{
println(it)
},
{
println("onError …Run Code Online (Sandbox Code Playgroud) moshi 1.11.0
Run Code Online (Sandbox Code Playgroud)
我有以下数据类是从 sportsapidata API 填充的
@JsonClass(generateAdapter = true)
data class PlayerEntity(
@Json(name = "player_id")
val playerId: Int,
val firstname: String,
val lastname: String,
val birthday: String,
val age: Int,
val weight: Int,
val height: Int,
)
Run Code Online (Sandbox Code Playgroud)
问题是,来自 API 的数据对于某些值可能为空,并且想知道创建数据类时的最佳实践是什么。
下面的数据显示weight和为空height,但在其他情况下也可能为其他值。
"data": [
{
"player_id": 2497,
"firstname": "Jay-Alistaire Frederick",
"lastname": "Simpson",
"birthday": "1988-12-01",
"age": 32,
"weight": 85,
"height": 180,
},
{
"player_id": 2570,
"firstname": "Simranjit",
"lastname": "Singh Thandi",
"birthday": "1999-10-11",
"age": 21,
"weight": null,
"height": null, …Run Code Online (Sandbox Code Playgroud) C99 gcc
我一直收到这个错误.我有一个主要的结构.在main中我试图使用calloc在堆栈上进行分配.我似乎无法找出问题所在.
谢谢你的建议,
错误:')'标记之前的预期表达式
/* global */
struct port_data_t
{
size_t task_id;
pthread_t *thread_id;
size_t start_port;
size_t number_ports;
} *port_data;
/* main function */
struct port_data_t *port_data = (struct task_data_t*) calloc(4, sizeof(port_data*));
Run Code Online (Sandbox Code Playgroud) 当使用sprintf将指针复制到字符串时,我有一些代码堆栈转储.我试图将动物的内容复制到一个名为output的新指针数组中.但是,我得到一个堆栈转储.
输出应该是以下内容:新动物兔新动物马新动物驴
我正确地走这条路吗?
非常感谢
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void p_init(const char **animals, char **output);
int main(int argc, char **argv)
{
char *animals[] = {"rabbit", "horse", "donkey", '\0'};
char **prt_animals = animals;
char *output[sizeof(*animals)];
/* print the contents here */
while(*prt_animals)
{
printf("Animal: %s\n", *prt_animals++);
}
/* copy and update in the output buffer */
p_init(*&animals, *&output);
getchar();
return 0;
void p_init(const char **animals, char **output)
{
while(*animals)
{
sprintf(*output, "new animal %s", *animals);
*output++;
}
}
Run Code Online (Sandbox Code Playgroud)