我正在尝试减少我的elf可执行文件的大小.我正在编译-ffunction-sections -fdata-sections和链接-gc-sections,但似乎我认为未使用的一些符号不会被丢弃.
在GNU工具链中是否有一些命令可以运行以找出正在使用的符号以及在哪里?
这是我的典型构建标志:
汇编: arm-none-eabi-g++.exe -Wall -O3 -mthumb -std=c++11 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -fsingle-precision-constant -ffunction-sections -fdata-sections
链接: arm-none-eabi-g++.exe -static -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -Wl,-gc-sections -Wl,-T"LinkerScript.ld
谢谢您的帮助.
我有一个项目,其中我有许多具有许多属性的对象,其值始终小于60,100和255之类的小数字.
我知道在进行数学运算时byte,有必要投射结果.但除此之外,使用a byte或者short所有这些属性是否有任何不利之处?或者另一种看待它的方式,使用bytes或shorts而不是int?
我编写了以下函数来使用NetworkStream异步读取函数(BeginRead和EndRead)实现超时功能.它工作正常,直到我注释掉该行Trace.WriteLine("bytesRead: " + bytesRead);.为什么?
private int SynchronousRead(byte[] buffer, int count)
{
int bytesRead = 0;
bool success = false;
IAsyncResult result = null;
result = _stream.BeginRead(
buffer, 0, count,
delegate(IAsyncResult r)
{
bytesRead = _stream.EndRead(r);
},
null);
success = result.AsyncWaitHandle.WaitOne(_ioTmeoutInMilliseconds, false);
if (!success)
{
throw new TimeoutException("Could not read in the specfied timeout.");
}
//If I remove this line, bytesRead is always 0
Trace.WriteLine("bytesRead: " + bytesRead);
return bytesRead;
}
Run Code Online (Sandbox Code Playgroud)
万一你想知道,我必须这样做,因为我最终需要针对.Net Compact …
我正在寻找一种方法来一致地处理所有.Net数据类型,所以我可以在下面创建任何类型实现IGetValue<out T>将转换为的模式IGetValue<object>.出于某种原因,如果T是a struct,它不起作用,我不明白为什么.有没有办法可以实现以下模式?
public interface IGetValue<out T>
{
T Value
{
get;
}
}
public class GetValue<T> : IGetValue<T>
{
public GetValue(T value)
{
_value = value;
}
private T _value;
public T Value
{
get { return _value; }
}
}
class Program
{
static void Main(string[] args)
{
IGetValue<string> GetString = new GetValue<string>("Hello");
IGetValue<int> GetInt = new GetValue<int>(21);
//This works!!!
if (GetString is IGetValue<object>)
{
Console.WriteLine("GetValue<string> is an IGetValue<object>");
}
else
{
Console.WriteLine("GetValue<string> …Run Code Online (Sandbox Code Playgroud)