0

The below is a code segment from the GNU Make software.These lines are taken from make.h .Can you please tell me what does #pragma alloca means .Does #if define (_AIX) means that the code #pragma alloca should run only of AIX is defined . The version of make is 3.75

/* AIX requires this to be the first thing in the file.  */

#if defined (_AIX) && !defined (__GNUC__)
 #pragma alloca
#endif

Please give me a detailed explanation.I am trying to read and learn GNU make .Where can can i find a detailed article of how GNU make works internally .

#Extra

It would be helpful if you can point me on how to read codes (of any opensource software) and learn.Its seems really a tough task to learn from code.Any help would be highly appreciated.

Midhun Raj
  • 925
  • 2
  • 7
  • 21
  • `alloca()` is [not a part of the C standard](https://stackoverflow.com/questions/2318306/is-alloca-part-of-the-c-standard), but is often present and requires enabling with the right `#define` or `#pragma`. It's a bit like `malloc()`, but allocates space on the stack, which is faster and need not be explicitly freed later; the memory is released on return. Regarding your other observation, that it is tough to learn to code, that is accurate and it just takes time, patience, practice and asking questions when you need to. You seem like you're on the right path. – Perette Nov 26 '21 at 13:17

1 Answers1

2

Can you please tell me what does #pragma alloca means

It (apparently, I just googled aix pragma alloca) means that on AIX systems, the system C compiler will provide alloca().

Does #if define (_AIX) means that the code #pragma alloca should run only of AIX is defined?

Yes, it does. If the _AIX preprocessor symbol is set, and the __GNUC__ symbol isn't, then the code is run.

__GNUC__ would be set when using GCC, and #pragma alloca isn't a thing on GCC.

I am trying to read and learn GNU make .Where can can i find a detailed article of how GNU make works internally . It would be helpful if you can point me on how to read codes (of any opensource software) and learn.Its seems really a tough task to learn from code.Any help would be highly appreciated.

You will want to choose a simpler program than Make to start with. How about busybox's implementation of ls?

In general, though, you'll probably want to learn how to skim programs – for instance, these three AIX-related lines are just a small detail and you're getting caught up in the weeds, so to speak.

AKX
  • 152,115
  • 15
  • 115
  • 172