问题列表 - 第14587页

C标准malloc'ing字符的潜在问题

在回答对我的另一种答案评论在这里,我找到了我想可能是在C标准(孔C1X,我没有检查的早期的,是的,我知道这是令人难以置信的可能性不大,我独自所有中行星的居民在标准中发现了一个错误).信息如下:

  1. 第6.5.3.4节("运营商规模")第2段规定"The sizeof operator yields the size (in bytes) of its operand".
  2. 该部分第3段指出:"When applied to an operand that has type char, unsigned char, or signed char, (or a qualified version thereof) the result is 1".
  3. 第7.20.3.3节描述void *malloc(size_t sz)但所有内容都是"The malloc function allocates space for an object whose size is specified by size and whose value is indeterminate".它根本没有提到用于论证的单位.
  4. 附件E开始时8是最小值,CHAR_BIT因此字符长度可以超过一个字节.

我的问题很简单:

在char为16位宽的环境中,将malloc(10 * sizeof(char))分配10个字符(20个字节)或10个字节?上面的第1点似乎表示前者,第2点表示后者.

任何比我更有C-standard-fu的人都有这个答案?

c malloc standards sizeof c11

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

MSBuild TFS内部版本号

我一直在使用SVN一段时间.最近我正在使用TFS的一个项目.在构建中,我喜欢在项目输出上追加/更新构建版本号.我在母版页上执行此操作,以便在应用程序中清晰可见.由于应用程序可以在多台计算机上运行,​​因此它是运行verison的便捷信息.

我在SVN世界中认识到:

  <!-- Import of the MSBuildCommunityTask targets -->
    <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
    <!-- to AssemblyInfo to include svn revision number -->
    <Target Name="BeforeBuild">
      <SvnVersion LocalPath="$(MSBuildProjectDirectory)" ToolPath="$(ProgramFiles)\CollabNet Subversion Client">
        <Output TaskParameter="Revision" PropertyName="Revision" />
      </SvnVersion>
      <Time>
        <Output TaskParameter="Year" PropertyName="Year" />
        <Output TaskParameter="Month" PropertyName="Month" />
        <Output TaskParameter="Day" PropertyName="Day" />
      </Time>
      <FileUpdate Files="MasterPage.master" Regex="svn revision: (\d+)\.(\d+)\.(\d+)\.(\d+)" ReplacementText="svn revision: $(Year).$(Month).$(Day).$(Revision)" />
    </Target>
Run Code Online (Sandbox Code Playgroud)

如上所示,"BeforeBuild"任务使用YYYY.MM.DD.SVNVERSION标记更新masterPage.master文件.

如何使用TFS作为源控件来实现此目的.我如何获得TFS内部版本号?

msbuild tfs msbuild-task tfsbuild

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

像Qt这样的C框架?

是否有一个功能齐全的C框架,类似于Qt

c qt frameworks

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

Android:有没有人遇到localhost HttpClient Connection Refused错误?

我只是想知道是否有人解决了这个问题.谷歌搜索提供了大量的帖子有这个问题,但没有一个有适当的答复.我试着使用和不使用代理的以下两段代码的每个组合:

/*********** URL METHOD ***************/
//URLConnection conn = aURL.openConnection(); 
//conn.connect(); 
//InputStream is = conn.getInputStream(); 

/*********** HTTP METHOD ***************/
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(urlString);
HttpResponse resp = client.execute(get);

InputStream is = resp.getEntity().getContent();
Run Code Online (Sandbox Code Playgroud)

我正在尝试连接到我的Intranet上的站点(它不是localhost).我尝试过以下方法:

  1. 在Eclipse设置中设置代理
  2. 设置我自己的localhost并编写一个带有url的小php脚本,连接到它然后从Intranet站点获取文件 - 这可以从浏览器中运行!当我使用10.0.2.2 IP地址时,它不起作用

有什么想法吗?

android http

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

在Delphi中使用XML的教程在哪里?

我需要一个关于使用XML文件的示例或教程.我想为一个人创建一个包含"记录"的文件,如下所示:

Name: Just Me
Age: 99
EMail: me@some.net

我想学习如何读写XML文件.

xml delphi

7
推荐指数
2
解决办法
8064
查看次数

浏览SVN存储库

我正在尝试浏览SVN存储库而不必检查它:

  • 是否有可能在本地(在Unix上)这样做?
  • 这是否可以通过ssh访问?

svn

51
推荐指数
4
解决办法
7万
查看次数

Clojure中的运算符重载

即使仔细查看Clojure上的文档,我也没有看到任何关于Clojure 是否支持运算符重载的直接确认.

如果确实如此,有人可以向我提供如何超载的快速信息,比方说,"+"运算符委托我们可以调用的一些预定义方法myPlus.

我对Clojure 新,所以非常感谢有人的帮助.

functional-programming operator-overloading clojure

16
推荐指数
2
解决办法
3061
查看次数

使用CruiseControl将头部SVN文件夹复制到Release文件夹

我刚刚开始使用CruiseControl.NET和nAnt,并且对整个过程的工作原理并不十分了解.我们目前在Visual Source"Safe"中拥有大部分解决方案,并使用AssemblyInfo文件自动为每个版本生成构建服务器标签.

我们正在将我们的VSS项目迁移到SVN,并相应地修改了项目构建文件以检出并更新SVN存储库.我们想要实现的是在源代码控制中获得源代码的副本,该副本与正在部署的项目的版本完全匹配.

我们的SVN设置如下:

svn://solution/  
    TRUNK/
    RELEASES/
         1.0.0/
         1.2.0/
    BRANCHES/
Run Code Online (Sandbox Code Playgroud)

因此,当我们强制构建我们的解决方案时,其assemblyinfo版本设置为1.3.0,我们希望构建服务器将TRUNK目录复制到RELEASES/1.3.0 /目录中.

SVN命令相当简单.svn copy src/directory dst/directory.但是我会在哪里放置此命令,以及如何获取目标的版本号?

在构建服务器上,这是.xml文件的示例:

    <sourcecontrol type="svn">
    <trunkUrl>svn://project/trunk</trunkUrl>
            <workingDirectory>D:\Builds\project\Src</workingDirectory>
            <executable>C:\Subversion\bin\svn.exe</executable>
    <username>sf_service_dev</username>
    <password>SFx4vi-r</password>
            <tagOnSuccess>true</tagOnSuccess>
    <cleanCopy>true</cleanCopy>
</sourcecontrol>
Run Code Online (Sandbox Code Playgroud)

在项目.build文件中我们有这个(当然还有很多):

<target name="Deploy_Release">
     <property name="fileandpathformyfile" value="${CCNetWorkingDirectory}\Bin\project.exe"/>
  <echo message="fileandpathformyfile is ${fileandpathformyfile}."/>
  <property name="ReleaseNumber" value="${fileversioninfo::get-file-version(fileversioninfo::get-version-info(fileandpathformyfile))}"/>
  <echo message="ReleaseNumber has been detected to be ${ReleaseNumber}."/>

  <!--Use version as needed-->

  <!--Create the release direcory-->
  <mkdir dir="${CCNetWorkingDirectory}\..\Releases\${ReleaseNumber}"/>
  <!--Copy stuff to the release directory-->
  <copy todir="${CCNetWorkingDirectory}\..\Releases\${ReleaseNumber}">
    <fileset basedir="${CCNetWorkingDirectory}\bin">
      <include name="*.dll" />
      <include name="*.exe" />
      <include name="*.config" />
      <include name="*.xml" /> …
Run Code Online (Sandbox Code Playgroud)

.net svn cruisecontrol.net nant

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

PHP的魔术方法__call在子类上

我的情况最好用一些代码来描述:

class Foo {
    function bar () {
        echo "called Foo::bar()";
    }
}

class SubFoo extends Foo {
    function __call($func) {
        if ($func == "bar") {
            echo "intercepted bar()!";
        }
    }
}

$subFoo = new SubFoo();

// what actually happens:
$subFoo->bar();    // "called Foo:bar()"

// what would be nice:
$subFoo->bar();    // "intercepted bar()!"
Run Code Online (Sandbox Code Playgroud)

我知道我可以通过bar()在子类中重新定义(以及所有其他相关方法)来实现这一点,但就我的目的而言,如果__call函数可以处理它们会很好.它会只是让事情很多整洁和更易于管理.

这可能在PHP?

php oop magic-methods

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

如何验证具有多个复选框的表单以检查至少一个

我正在尝试使用jquery的validate插件验证表单.我想要求用户检查组中的至少一个复选框,以便提交表单.这是我的jquery代码:

$().ready(function() {
$("#subscribeForm").validate({
   rules:   { list: {required: "#list0:checked"} },
   messages:  { list:  "Please select at least one newsletter"}                                                        
 });
 });
Run Code Online (Sandbox Code Playgroud)

这是html表单:

<form action="" method="GET" id="subscribeForm">
<fieldset id="cbgroup">
    <div><input name="list" id="list0" type="checkbox"  value="newsletter0" >zero</div>
    <div><input name="list" id="list1" type="checkbox"  value="newsletter1" >one</div>
    <div><input name="list" id="list2" type="checkbox"  value="newsletter2" >two</div>
</fieldset>
<input name="submit" type="submit"  value="submit">
Run Code Online (Sandbox Code Playgroud)

问题是即使没有检查任何内容,表单也会提交.我该如何解决这个问题?

html javascript checkbox jquery-validate

40
推荐指数
5
解决办法
13万
查看次数