> For the complete documentation index, see [llms.txt](https://docs.aic-eec.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aic-eec.com/c-c++-for-embedded-programming/c-c++-preprocessing/pragma-directive.md).

# Pragma directive

{% hint style="info" %}

#### Pragma : เทคนิคที่ทำการเตรียมตัว Compiler ที่จะนำมาใช้งานรวมถึง option เสริมต่างๆให้กับฟังก์ชันที่กำหนด รวมถึงเลือกสถาปัตยกรรมที่จะใช้โดยจะแบ่งกรณีการใช้งานดังนี้

{% endhint %}

* ใช้ในการเลือก Compiler เช่น

```cpp
#pragma GCC
```

* ใช้ในการเพิ่ม option เสริม

```cpp
#pragma GCC push_options
```

* ใช้ในการป้องกันการใช้ฟังก์ชันบางอย่าง

```cpp
#pragma GCC poison printf
```

* ใช้ในการเลือกสถาปัตยกรรมที่ใช่ในการ Compile

```cpp
 #pragma GCC target (“arch=armv6”)
```

#### Example C++

```cpp
#include <bits/stdc++.h>
using namespace std;
	
void func1();
void func2();

#pragma startup func1
#pragma exit func2

void func1()
{
	cout << "Inside func1()\n";
}

void func2()
{
	cout << "Inside func2()\n";
}

int main()
{
	void func1();
	void func2();
	cout << "Inside main()\n";

	return 0;
}

// This code is contributed by shivanisinghss2110

```

#### Example C

```cpp
#include <stdio.h>

void func1();
void func2();

#pragma startup func1
#pragma exit func2

void func1()
{
	printf("Inside func1()\n");
}

void func2()
{
	printf("Inside func2()\n");
}

int main()
{
	void func1();
	void func2();
	printf("Inside main()\n");

	return 0;
}

```

#### Output

```cpp
Inside func1()
Inside main()
Inside func2()
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.aic-eec.com/c-c++-for-embedded-programming/c-c++-preprocessing/pragma-directive.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
