---
title: "Linux C 多线程编程使用-D_REENTRANT"
author: "luckyclouds"
date: "2011-06-29T17:15:40Z"
tags: ["C", "C#", "C++", "多线程", "编程"]
categories: ["编程语言"]
slug: "linux-c-d-reentrant"
draft: false
lastmod: "2011-06-29T17:15:40Z"
id: 1109585
url: "https://luckyclouds.iteye.com/blog/1109585"
---

1、多线程编译使用-D_REENTRANT，如：
gcc -D_REENTRANT -lpthread -o test test.c
2、头文件定义了一些标准库函数的reentrant变化的原型
3、重新定义了errno，让多线程函数有一个自己的安全的errno，而不是全局的。宏定义如下：
#define errno (*(__errno_location()))