我正在处理一个有大小限制的项目,所以我不想链接到 Visual Studio 的 C 运行时。我使用静态运行时 (/MT) 和/NODEFAULTLIB:LIBCMT 标志来执行此操作。我已经通过检查 VS 附带的运行时源解决了大部分问题。但是,编译器仍然会生成一些未解析的外部符号:
_chkstk:生成用于检查大于 4k 的函数的堆栈。我可以关闭它或提供虚拟功能吗?
__libm_sse2_pow 和其他 SSE 调用:我可以通过关闭 SSE 代码生成来避免这些,但如果可能的话,我希望拥有它们。这些符号似乎来自 Intel 库(libmmd.lib?)。为什么这部分仍然是 C 运行时?
_ftol2_sse:将浮点型转换为长整型。尽管关闭了 SSE 代码生成,我仍然得到这个。
_CIpow:另一个 pow 函数。我想知道为什么编译器生成这个而不是 SEE 一个。
是否有控制此代码生成的任何设置、预处理器宏或编译指示?我也尝试过使用 visual studio 6.0 SP6 中的 msvcrt.lib,但我使用的某些函数无法与 VS2010 编译器一起使用。
编辑:
_chkstk 可以通过在相关函数前加上可以在CRT中找到Visual Studio 附带的源代码。#pragma check_stack(off)来关闭。
_CIpow 有点难。它是使用特殊调用约定的 pow 的固有版本。我找不到关闭它的方法,所以我最终自己在汇编程序中重新实现了它。我在这里得到了一些灵感:How to: pow(real, real) in x86 .我有一段时间没有做汇编程序了,这是我第一次在 x86 上做。我没有对所有情况进行测试,所以不能保证!如果您有任何改进建议或发现错误,请告诉我。
void __cdecl _CIpow(void)
{
// implementation of pow function as 2^(y*log2(x)). this is the
// intrinsic version so base and exponent are already on the fpu
// stack ST0 and ST1. the result is pushed to ST0.
// note that earlier rounding for fist was set to truncate
int temp;
__asm {
// values are repushed, cause fyl2x will overwrite them both
fld st(0) // push ST0 to ST0
fld st(2) // push ST2 (ex ST1) to ST0
fyl2x // ST1 = ST1*log2(ST0), pop ST0
fist temp // assumes truncate rouning
fisub temp // S0 = S0 - temp
f2xm1 // ST0 = (2^ST0)-1
fld1 // push 1 to ST0
faddp st(1),st(0) // ST1 = ST1 + ST0, pop ST0
fild temp // push temp to ST0
fxch // swap ST0 and ST1
fscale // ST0 = inc exp of ST0 by ST1
fxch // put reslut in ST1
fstp st(0) // pop ST0
}
}
最佳答案
这是我必须从 VS2010 中的默认 Win32 项目更改的内容:
调试
发布
必须做更多的事情来处理 float :
我遇到了一个 interesting blog post关于使用 VS 构建极简程序,我在其中找到了一些此类信息;如果您仍然有问题,可能会有其他提示。
通过所有这些调整,我能够编译和链接一个将 float 转换为 long 并调用一些 pow() 函数的程序。发布版本只有 3.5 KB,其中包括嵌入式 list 。
关于c - 在没有 C 运行时的情况下与 VS2010 链接时未解析的符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7420927/
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
在railstutorial中,作者为什么选择使用这个(代码list10.25):http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-usersnamespace:dbdodesc"Filldatabasewithsampledata"task:populate=>:environmentdoRake::Task['db:reset'].invokeUser.create!(:name=>"ExampleUser",:email=>"example@railstutorial.org",:passwo
我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/
在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
这是在Ruby中设置默认值的常用方法:classQuietByDefaultdefinitialize(opts={})@verbose=opts[:verbose]endend这是一个容易落入的陷阱:classVerboseNoMatterWhatdefinitialize(opts={})@verbose=opts[:verbose]||trueendend正确的做法是:classVerboseByDefaultdefinitialize(opts={})@verbose=opts.include?(:verbose)?opts[:verbose]:trueendend编写Verb
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
Sinatra新手;我正在运行一些rspec测试,但在日志中收到了一堆不需要的噪音。如何消除日志中过多的噪音?我仔细检查了环境是否设置为:test,这意味着记录器级别应设置为WARN而不是DEBUG。spec_helper:require"./app"require"sinatra"require"rspec"require"rack/test"require"database_cleaner"require"factory_girl"set:environment,:testFactoryGirl.definition_file_paths=%w{./factories./test/