# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
