gcc 4.4.1 c89
我有以下代码片段:
#include <stdlib.h>
#include <stdio.h>
char *buffer = malloc(10240);
/* Check for memory error */
if(!buffer)
{
fprintf(stderr, "Memory error\n");
return 1;
}
printf("sizeof(buffer) [ %d ]\n", sizeof(buffer));
Run Code Online (Sandbox Code Playgroud)
但是,sizeof(缓冲区)总是打印4.我知道char*只有4个字节.但是,我已经分配了10kb的内存.那么尺寸不应该是10240吗?我想知道我在想什么?
非常感谢任何建议,
gcc 4.4.4 c89
我正在使用下面的代码.但是,我一直得到相同的数字:
size_t i = 0;
for(i = 0; i < 3; i++) {
/* Initialize random number */
srand((unsigned int)time(NULL));
/* Added random number (simulate seconds) */
add((rand() % 30) + 1);
}
Run Code Online (Sandbox Code Playgroud)
我想回到0到30.但是,我最后一次跑这个三次得了17次.
非常感谢,
git version 1.7.1
svn, version 1.6.12
Ubuntu 10.10
Run Code Online (Sandbox Code Playgroud)
我只是git而且我使用过svn.但我没有一起使用过.我有一个git存储库,我不得不将我的存储库更多地转换为subversion版本.所以我一直在使用git-svn.大部分时间都可以.但是,我发现围成一圈.
我是唯一一个从事这个项目的人.
我对我的分支进行了一些更改.我然后上演他们:
git stage gateway.c
Run Code Online (Sandbox Code Playgroud)
然后在本地将它们提交给git:
git commit m"Made some changes"
Run Code Online (Sandbox Code Playgroud)
然后我想将它们提交给颠覆.获取最新更新:
git svn rebase
Run Code Online (Sandbox Code Playgroud)
然后我收到以下消息:
It seems that I cannot create a rebase-apply directory, and
I wonder if you are in the middle of patch application or another
rebase. If that is not the case, please
rm -fr /home/joe/projects/gateway/.git/rebase-apply
and run me again. I am stopping in case you still have something
valuable there.
rebase refs/remotes/trunk: command returned error: 1 …Run Code Online (Sandbox Code Playgroud) 我正在使用不同版本的gcc的2台不同机器上编译我的源代码.
cflags c89
-Wall -Wextra -Wunreachable-code -g -m32 -D_DEBUG -O0 -D_LARGEFILE64_SOURCE -D_REETRANT -D_THREAD_SAFE
Run Code Online (Sandbox Code Playgroud)
一个是redhat-4
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
Linux 203_test_server 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
一个是Fedora 18
gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)
Linux localhost.localdomain 3.8.1-201.fc18.x86_64 #1 SMP Thu Feb 28 19:23:08 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
我的fedora 18编译没有错误.但是,在redhat 4机器上我遇到了一些错误.
channel.h:35: error: redefinition of typedef ‘channel_t’
internal.h:19: error: previous declaration of ‘channel_t’ was here
Run Code Online (Sandbox Code Playgroud)
我认为错误只是一个循环问题.但是,使用相同的代码库,在2台不同的机器上进行编译真的可以使用2个不同版本的gcc来改变它们吗?
我在考虑使用较新版本的编译器会产生更多错误,因为较新的编译器可能会更严格.
这不是解决错误的问题,而是编译器的一般问题. …
Android Studio 1.5
Run Code Online (Sandbox Code Playgroud)
我调用chat_profile_header了这个布局,将在许多布局中使用.我已经设定background为靛蓝色.问题是当我在其他布局中包含此标题时,我希望能够根据该布局的主题更改背景颜色.标题中的所有内容都将保持不变.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/profile_header_indigo_500">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/photorace"
android:layout_centerVertical="true"/>
<TextView
android:id="@+id/tvProfileName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/profile_image"
android:layout_toEndOf="@id/profile_image"
android:layout_centerVertical="true"
android:layout_marginLeft="8dp"
android:fontFamily="sans-serif"
android:textColor="@android:color/white"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这里我使用的是此布局中包含的上述标题.但是,基于这个主题,我想将标题更改为另一种background颜色灰色.但是,我认为我不能覆盖背景颜色属性.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<include
layout="@layout/chat_profile_header"
android:background="@color/child_header_lighter_grey"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/rvParentList"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点,而无需根据背景创建不同的页眉布局.似乎有很多重复.
C#2008/3.5 SP1
我想检查应用程序是否第一次运行.我已经开发了一个应用程序,一旦安装在客户端计算机上.我想检查它是否是第一次运行.
我已经安装了使用Windows安装程序项目.
if (System.Deployment.Application.ApplicationDeployment.CurrentDeployment.IsFirstRun)
{
// Do something here
}
Run Code Online (Sandbox Code Playgroud)
上面的代码适用于clickonce开发.但是我怎么能用Windows安装程序做类似的事情.
我想在应用程序安装时添加一个注册表.当程序第一次运行时(true),请检查此注册项目.一旦它第一次运行,编辑注册表为(false).
但是,而不是使用注册表,有没有更好的方法,我可以使用?
我已经构建了一个应用程序,并使用ClickOnce在Windows服务器上发布.客户端转到URL,可以下载并运行应用程序.
客户端现在正在更改其服务器以运行Ubuntu.可以在运行Ubuntu的服务器上发布ClickOnce应用程序吗?
Ubuntu的版本是8.10.我正在使用Visual Studio 2008 SP1和C#.
我使用下面的简短文章添加了多语言.
当您添加例如德语时,您将拥有以下文件:formMain.resx formMain.de-DE.resx formMain.Designer.cs formMain.cs
在第一个文件中,您将拥有中性语言的资源,如字符串,图像,..
所以现在你需要为代码中使用的字符串添加资源.添加一个新的资源文件并将其命名为formMain.Strings.resx然后我将为每个应该翻译的字符串输入名称,值对.当您添加资源文件时,它会自动输入,因为另一个名为formMain.Strings.Designer.cs的文件会在resx设计器的每个关闭时自动重新生成.
添加名为formMain.Strings.de-DE.resx的另一个资源.从以前的资源添加相同的Name键,只需使用相应的德语单词更改Value.现在要从源访问创建的资源,它将是这样的.
MessageBox.Show(formMain_Strings.SameStringName);
但是,我已将我改为泰语.当我在VS中运行我的应用程序时,一切正常.
但是,只要我在客户端计算机上添加安装项目并安装它就不会将语言更改为泰语,只保留默认语言.
所以我已经将资源文件和th-TH dll添加到项目设置中.我仍然遇到同样的问题.
Packaging file 'Lang.Strings.resx'...
Packaging file 'MultiLanguage.resources.dll'...
Packaging file 'MultiLanguage.exe'...
Packaging file 'Lang.Strings.th-TH.resx'...
Run Code Online (Sandbox Code Playgroud)
因为在visual studio中运行时一切正常.有没有什么我需要做的就是让它在安装后运行.我保留默认值的每个文件的所有属性.
非常感谢,
=========
static void Main()
{
System.Threading.Thread.CurrentThread.CurrentUICulture =
new System.Globalization.CultureInfo("th-TH");
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
Run Code Online (Sandbox Code Playgroud) Windows VC++ 2008 linux gcc 4.4.3
我有以下问题.当我在Windows上编译时,我需要ws2_32库.但是,当我在linux上编译时,我不需要链接它.
我的CMakeLists.txt
INCLUDE_DIRECTORIES($CLIENT_SERVER_SOURCE_DIR/client)
INCLUDE_DIRECTORIES($CLIENT_SERVER_SOURCE_DIR/cltsvr_ults)
# Link the library
LINK_DIRECTORIES($CLIENT_SERVER_DIR/client)
# Add the executable
ADD_EXECUTABLE(clt test_clt)
# Link the executable to the client library
IF(WIN32)
TARGET_LINK_LIBRARIES(clt client ws2_32)
ENDIF(WIN32)
IF(CMAKE_COMPILER_IS_GNUCXXX)
TARGET_LINK_LIBRARIES(clt client)
ENDIF(CMAKE_COMPILER_IS_GNUCXXX)
Run Code Online (Sandbox Code Playgroud)
我尝试在linux下编译失败.使用上述条件.但是,它总是试图链接ws2_32,我得到一个编译错误.我认为条件不起作用,因为它总是落在WIN32条件下.
非常感谢任何建议,
android studio 2.1. preview 4
Run Code Online (Sandbox Code Playgroud)
我正在创建一个junit4 unit test测试来打开原始目录中包含的文件.
但是,每次代码运行时我都可以使用空指针openRawResource.
这是我试图测试的功能.这在实际设备上运行时有效.但不是在单元测试中.
public String getNewsFeed(Context mContext) {
InputStream inputStream = mContext.getResources().openRawResource(R.raw.news_list); // Null pointer
Writer writer = new StringWriter();
char[] buffer = new char[1024];
try {
InputStreamReader inputReader = new InputStreamReader(inputStream, "UTF-8");
BufferedReader bufferReader = new BufferedReader(inputReader);
int n;
while ((n = bufferReader.read(buffer)) != -1) {
writer.write(buffer, 0, n);
}
inputStream.close();
}
catch (IOException ioException) {
return "";
}
return writer.toString();
}
Run Code Online (Sandbox Code Playgroud)
这是我的测试用例
@RunWith(MockitoJUnitRunner.class)
public class NewsListPresenterTest { …Run Code Online (Sandbox Code Playgroud)