ICMAKE Part 2
Icmake allows the construction of user-defined functions in a makefile. The definition of a function must follow an ansi-C-like syntax, however, minor differences exist between an icmake function and a C function. These differences are highlighted in this section.
The definition of a function must follow the syntax:
Optionally, the return type of the function is specified. The type is void, int, string or list. The default return type is int.
When a function explicitly returns using a return statement, the returned value must match the return type. If a function does not use a returns statement, an undefined value is returned. Functions which are defined as void can also use the return statement, albeit without an expression.
Following the optional return type, the function name must follow. The name must be an identifier, i.e., the first character must be an underscore or a character of the alphabet, and optional following characters may be underscores or alphanumerics.
Following the function name, a ( is expected.
A parameter list may follow, consisting of parameter specifications separated by , (this is referred to as an ansi-C parameter list). Parameter specifications consist of the parameter type (int, string or list) and the parameter name (an identifier).
In contrast to C, icmake does not allow user-defined functions to have a variable number of parameters.
Following the optional parameter list, a ) is expected.
Next, the code of the function is expected: statements enclosed by { and }.
Following the first { of the code block, local variables may be defined. The definition of local variables consists of the variable type, one or more variable names separated by commas, and a semicolon.
In contrast to C, local variables can only be defined immediately after the outer curly brace of the function code block. Variables cannot be defined within a block of statements.
In contrast to C, icmake initializes all local variables to zero.
Icmake does not allow forward references. This means that a function may be called only after it has been defined. Recursive function calls are accepted. Furthermore, the statement which calls a function must supply the exact number of required arguments and each argument type must match the parameter list of the function. The built-in functions are predefined and may therefore be used anywhere within functions.
The code section of a makefile must contain at least one user-defined function, called main(). The execution of a makefile starts at this function. The run-time support system of icmake provides three arguments which the function main() may use. The arguments are used to hold the command line parameters of the icmake invocation and the environment setting.
The three arguments are most commonly referred to as argc, argv and envp. Argc is an int argument, holding the number of command line parameters. Argv is a list, holding the command line parameters themselves. Envp is a list holding the environment setting. A definition of the main() function which uses all arguments argc, argv and envp is given below:
int main(int argc, list argv, list envp)
{
// statement(s)
}
Users may wish to define the main() function without arguments when the command line parameters need not be examined. In this case, the main() function can be defined as:
int main
{
//statements(s)
}
It is also possible to define the main() function to use only the first or the first two arguments (argc and argv). A sample makefile which prints its command line arguments is given below. The functions printf() and element() used in this example are discussed in the function-section below:
The arguments passed to main() functions as the list argv are:
void main (int argc, list argv)
{
int
i;
for (i = 0; i < argc; i++)
printf ("Argument ", i, " is ", element (i, argv), "\n");
}
The name of the binary makefile which is interpreted by icm-exec. This is always the first argument.
Remaining arguments are those arguments which were explicitly supplied on the command line.
For example, to supply the arguments one, two and three to a makefile called try.im, one of the following invocations can be used:
icmake test - one two three
or:
icmake -i test.im one two three
In both cases, the first int argument of the function main() will have the value four. The first element of the list argv holds the name of the binary makefile (test.bim); the remaining elements of argv hold the arguments one, two and three.
The third argument of main(), envp, is a list holding the setting of the environment (the environment variables). An example of such a variable is PATH, specifying where the operating system searches for executable files. The envp list consists of pairs of elements, where each first element of the pair holds the variable name (e.g., the string PATH) and where the second element of each pair holds the value of the variable (e.g., a list of directories where executable files may be found).
An example of a makefile which prints the settings of environment variables is given below:
void main (int argc, list argv, list envp)
{
int
i;
for (i = 0; i < sizeof (envp); i += 2)
printf ("variable ", element (i, envp), " has value ",
element (i + 1, envp));
}
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
| Introduction to MapReduce with Hadoop on Linux | Jun 05, 2013 |
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Linux Systems Administrator
- Validate an E-Mail Address with PHP, the Right Way
- Introduction to MapReduce with Hadoop on Linux
- RSS Feeds
- Weechat, Irssi's Little Brother
- New Products
- Developer Poll
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




45 min 47 sec ago
1 hour 31 min ago
1 hour 41 min ago
1 hour 46 min ago
3 hours 56 min ago
3 hours 57 min ago
4 hours 42 min ago
5 hours 31 min ago
5 hours 54 min ago
7 hours 31 min ago