我正在使用最新版本的Xcode 4开发Cocoa应用程序,我想将动态库链接到我的项目(dylibs
).
我读的地方,在我的项目库添加是不够的,因为我有运行install_name_tool
,并otool
让我的项目中使用我的项目被捆绑的库.
我已经阅读了手册页install_name_tool
,但我不明白为什么我必须这样做.
图书馆如何运作?特别感兴趣的是应用程序和库具有指向我机器中特定位置的路径的部分,例如/usr/local/lib/mylibrary.dylib
运行时otool -L
我有一个程序的两个版本基本上做同样的事情,在文件中得到一行的最大长度,我有一个大约8千行的文件,我的C代码有点原始(当然!)比我在C++中的代码.C程序运行大约需要2秒钟,而C++程序运行需要10秒钟(我正在测试两个案例的同一文件).但为什么?我期待它花费相同的时间或更多但不会慢8秒!
我在C中的代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if _DEBUG
#define DEBUG_PATH "../Debug/"
#else
#define DEBUG_PATH ""
#endif
const char FILE_NAME[] = DEBUG_PATH "data.noun";
int main()
{
int sPos = 0;
int maxCount = 0;
int cPos = 0;
int ch;
FILE *in_file;
in_file = fopen(FILE_NAME, "r");
if (in_file == NULL)
{
printf("Cannot open %s\n", FILE_NAME);
exit(8);
}
while (1)
{
ch = fgetc(in_file);
if(ch == 0x0A || ch == EOF) // \n or \r or \r\n or end of …
Run Code Online (Sandbox Code Playgroud) 有没有更干净的方法来获取吠叫的狗的列表?
public abstract class Mammal
{
public bool sweat_glands;
public bool is_aquatic;
}
public class Whale: Mammal
{
public Whale() { is_aquatic = true; }
}
public class Dog: Mammal
{
public bool Barks { get; set; }
public Dog() { is_aquatic = false; }
}
class Program
{
static void Main(string[] args)
{
List<Mammal> mammals = new List<Mammal>();
mammals.Add(new Whale());
mammals.Add(new Dog() { Barks = false });
List<Dog> dogs = (from c in mammals where c is Dog && …
Run Code Online (Sandbox Code Playgroud)