---
title: "解决TCC在Windows下面提示：unknown constraint 't' 的问题"
author: "larlf"
date: "2013-06-30T15:01:49Z"
tags: ["tcc"]
categories: ["编程语言"]
slug: "tcc-windows-unknown-constraint-t"
draft: false
lastmod: "2013-06-30T15:01:49Z"
id: 1896620
url: "https://larlf.iteye.com/blog/1896620"
---

在Windows下用TCC进行编译时，如果使用到了<math.h>里的一些函数，有可能会报这个Error :
../../deps/tcc/include/math.h:341: error: unknown constraint 't'
错误的原因是在Win32平台上处理__asm__时，没有处理下面几个约束：
f 表示使用浮点寄存器
t 表示使用第一个浮点寄存器
u 表示使用第二个浮点寄存器

从网上找到了解决方法：
从TCC的源码中找到处理这部分的：i386-asm.c

然后在Line1031加入：
        case 'f':
        case 't':
        case 'u':
在Line1211加入：
        case 'f':
        case 't':
        case 'u':
            break;

然后重新编译TCC。

Windows下重新编译TCC的方式为：
一、安装MinGW
二、配置Path，以方便运行GCC
三、进入TCC的目录，如果编译32位的，把build-tcc.bat下面两句删除：
@if _%PROCESSOR_ARCHITEW6432%_==_AMD64_ goto x86_64
@if _%PROCESSOR_ARCHITECTURE%_==_AMD64_ goto x86_64
四、执行build-tcc.bat，此目录下出现tcc.exe说明编译成功
