الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

ما فائدة التوجيه #pragma

مغلق
بدأه mhammad في 9 ديسمبر 2002 · 1 رد · 1,511 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله

السؤال كما هو في العنوان

وشكرا

#2

السلام عليكم ...

أمر التوجيه pragma# يسمح للمبرمج بكتابة أوامر إلى المترجم الذي يستخدمه المبرمج في كتابة برنامجه في وقت الترجمه، بكلام ثاني في بعض الحالات تود توجيه أمر للمترجم من داخل السورس كود و ليس من سطر الأوامر عند مناداة المترجم .

الجدير بالأشارة ان كل مترجم سي++ يدعم مجموعة تختلف من الخيارات للتوجية pragma# .

اكثر استخدام لأمر التوجيه pragma# في الفيجوال سي++ في في إطفاء و تشغيل التحذير من سطر معين في الكود، يلجأ له المبرمجون لكي لا يظهر عند الترجمة اي تحذير، طبعا التحذير مفيد لانه ينبهك إلى سطر ممكن ان ينتج عنه Bug و لكن إذا كنت تعرف ما تقوم به فيفضل ان تقول للمترجم لكي لا يطبعه لك عند الترجمه .

مثال على ال pragma# :

Places a linker option in the object file. You can use this comment-type to specify 

a linker option instead  placing the option on the Link tab of the Project Settings 

dialog box. For example, you can specity the /include option to force the inclusion 

of a symbol:



#pragma comment(linker, "/include:__mySymbol")



user



Places a general comment in the object file. The commentstring parameter 

contains the text of the comment. This comment record is ignored by the linker.



The following pragma causes the linker to search for the EMAPI.LIB library 

while linking. The linker searches first in the current working directory and then 

in the path specified in the LIB environment variable.



#pragma comment( lib, "emapi" )



The following pragma causes the compiler to place the name and version 

number of the compiler in the object file:



#pragma comment( compiler )



Note   For comments that take a commentstring parameter, you can use a macro in any 

place where you would use a string literal, provided that the macro expands 

to a string literal. You can also concatenate any combination of string literals 

and macros that expand to string literals. For example, the following statement 

is acceptable:



#pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ )

تقبل تحياتي ...

هذا الموضوع مغلق.

مواضيع مشابهة