Sponsored Content
Full Discussion: C++ application development
Top Forums Programming C++ application development Post 302701525 by Corona688 on Sunday 16th of September 2012 01:30:49 PM
Old 09-16-2012
The larger the project, the more work must be done when you end up ripping out all the IDE garbage to re-import into a newer or different IDE.

It doesn't help as much as you think, either, if you learn what you're doing first, which I think you should do at the very least! If you've never compiled anything yourself, never used a makefile, most of the options in an IDE will never make sense. It's not like makefiles are hard. Put all these files in the same folder and run make:

Code:
// libraryfunction.c

double square(double value)
{
        return(value*value);
}

Code:
// libraryfunction.h

#ifndef __LIBRARYFUNCTION_H__
#define __LIBRARYFUNCTION_H__

extern double square(double);

#endif/*__LIBRARYFUNCTION_H__*/

Code:
//main.c
#include "libraryfunction.h"
#include <math.h>
#include <stdio.h>

int main(void)
{
        printf("%f\n", square(sin(0.5)));
        return(0);
}

Code:
# Makefile

# Built-in variable for linker, defines libraries.
LDFLAGS=-lm
# Built in variable for CC, defines compile flags
# For C++ the simlar variable CXXFLAGS is used.
CFLAGS=-ggdb

# Note the eight spaces in front is actually a tab and MUST BE a tab
myapp:main.o library.o
        $(CC) $(LDFLAGS) $^ -o $@

...and that's a complete makefile. It knows how to convert .c and .cpp files into .o files by itself, so you just make a rule which builds your application out of .o files.

Whenever your .c files are newer than your .o files it rebuilds the .o files. Whenever your .o files are newer than myapp, it rebuilds myapp.

$@ is a special variable for 'output file'. It becomes myapp.
$^ is a special variable for 'input files'. It becomes main.o library.o.

Last edited by Corona688; 09-16-2012 at 02:38 PM..
This User Gave Thanks to Corona688 For This Post:
 

We Also Found This Discussion For You

1. Shell Programming and Scripting

Difference between development and Production unix servers for a application??

Hi all I am running a major script of my application in development for implementing code changes for process improvement in time. The script runs in production once in a month . It takes 8 hours 30 mins in Production server . what surprice me is , when I run the same script in development server... (9 Replies)
Discussion started by: sakthifire
9 Replies
postwait(2)							System Calls Manual						       postwait(2)

NAME
postwait: pw_getukid(), pw_wait(), pw_post(), pw_postv(), pw_getvmax() - lightweight synchronization mechanism SYNOPSIS
DESCRIPTION
Postwait is a fast, lightweight sleep/wakeup mechanism that can be used for synchronization by cooperating kernel threads within a single process or between separate processes. A thread calls to block. It resumes execution when it is posted by another thread, the call expires, or is signaled. If one or more posts are already pending, returns immediately. Threads using postwait are identified by their ukid. A thread retrieves its ukid by calling It shares this ukid with anyone it chooses by any means it considers appropriate (for example, shared memory). is called with a timeout ts. If ts is NULL, the thread will not timeout. It will remain blocked until posted or a signal wakes it up. If ts points to a zero-valued timespec, will return immediately with a value (and indicating whether or not it was posted. If ts points to a timespec whose value is greater than zero, the thread will block for that amount of time unless it is posted or inter- rupted by a signal, in which case the timespec pointed to by ts is updated with the remaining time. The return value and are set to indi- cate the reason the call returned. is used to post many threads with a single call. It posts to all threads in the targets array. An value for each target is returned in the errors array. (0 indicates success.) If the errors pointer is zero, no target-specific errors are copied out. There is a maximum number of threads that can be posted with a single call. This value is returned by Posts sent to a kernel thread that already has a post pending against it are discarded. RETURN VALUE
returns 0 if it succeeds, -1 otherwise. returns 0 if posted, -1 otherwise. returns 0 if the post succeeds, -1 otherwise. returns 0 if every post succeeds, -1 otherwise. returns the maximum number of kernel threads that can be posted with a single call to ERRORS
sets to one of the following values if it fails: ukid points to an illegal address. The reliable detection of this error is implementation dependent. sets to one of the following values if it fails: was called with a timeout of 0 but the caller has no post(s) pending. was called with a timeout that expired. ts points to an illegal address. The reliable detection of this error is implementation dependent. was interrupted by a signal. The timespec pointed to by ts is invalid. sets to one of the following values if it fails: The ukid refers to a non-existent kernel thread. sets to one of the following values if it fails: targets points to an illegal address. The reliable detection of this error is implementation dependent. errors points to an illegal address. The reliable detection of this error is implementation dependent. count is less than 0. count exceeds the maximum value (as returned by A ukid refers to a non-existent kernel thread. postwait(2)
All times are GMT -4. The time now is 08:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy