How to use CoreFoundation in QuickTime SDK for Windows?

夙愿已清 提交于 2019-12-08 19:29:25

YES!!!
I finally succeeded!
You can add CoreFoundation.dll statically to LDFLAGS MakeFile. (if installed itunes in your system, you can find this file on "program files/common files/apple...")
I've Compiled this code so much easier!

#include <stdio.h>
#include <stdlib.h>
#include <CoreFoundation/CoreFoundation.h>

#define BufferSize 1000

void show(CFStringRef formatString, ...) {
    CFStringRef resultString;
    CFDataRef data;
    va_list argList;

    va_start(argList, formatString);
    resultString = CFStringCreateWithFormatAndArguments(NULL, NULL, formatString, argList);
    va_end(argList);

    data = CFStringCreateExternalRepresentation(NULL, resultString, CFStringGetSystemEncoding(), '?');

    if (data != NULL) {
        printf ("%.*s\n\n", (int)CFDataGetLength(data), CFDataGetBytePtr(data));
        CFRelease(data);
    }

    CFRelease(resultString);
}

int main(){
    CFMutableStringRef mutStr;
    UniChar *myBuffer;

    myBuffer = malloc(BufferSize * sizeof(UniChar));
    mutStr = CFStringCreateMutableWithExternalCharactersNoCopy(NULL, myBuffer, 0, BufferSize, kCFAllocatorNull);
    CFStringAppend(mutStr, CFSTR("eAmin. "));

    show(CFSTR("Hello, %@"), mutStr);

    CFRelease(mutStr);
    free(myBuffer);

   return 0;
}


Edited & none problem makefile:

CC = gcc
LDFLAGS = "CoreFoundation.dll"
CFLAGS = -ICIncludes

all: StringExample.c
$(CC) $(CFLAGS) $(LDFLAGS) -o StringExample StringExample.c -static


Good Luck!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!