LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-31-2007, 07:33 AM   #1
Jacko123
LQ Newbie
 
Registered: Mar 2007
Posts: 13

Rep: Reputation: 0
Add preprocessor from console


Hello,
I have defined some preprocessor into my project. Something like

Code:
#ifdef _ENCRYPTION_
//perform encryption activity
#endif
//do normal operation
How to add this preprocessor into my project from the terminal, so that I can perform encryption activity?

Thanks
 
Old 08-31-2007, 07:45 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
I don't quite get what you mean. If you really have the //comments, then you have this:
Code:
... misc code...
//perform encryption activity
... misc code...
//do normal operation
... misc code...
Then this should do what you want:
Code:
find /path/to/project -type f
 -exec grep -Fxq '//perform encryption activity' '{}' \;
 -exec grep -Fxq '//do normal operation' '{}' \;
 -exec sed -i -e '/^\/\/perform encryption activity$/ i#ifdef _ENCRYPTION_' -e '/^\/\/do normal operation$/ i#endif' '{}' \;
This is a single command (one line), broken into several lines here for better readability.

This shell command finds files that contain both comments, and inserts the preprocessor commands above the comments.
I did not test, so try with a test folder first.

Yves.

Last edited by theYinYeti; 08-31-2007 at 07:47 AM.
 
Old 08-31-2007, 07:55 AM   #3
Jacko123
LQ Newbie
 
Registered: Mar 2007
Posts: 13

Original Poster
Rep: Reputation: 0
Sorry,
what I meant was how to add the preprocessor (_ECNRYPTION_) to the makefile from the terminal.

for eg.
:>qmake ce.pro //creates a makefile
:>make //compiles

In the above example how to add the preprocessor (_ECNRYPTION_) to the makefile generated, from the terminal.

Thanks
 
Old 08-31-2007, 09:04 AM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
I think what you looking for is the -D option for gcc
From man gcc:
Quote:
-D name
Predefine name as a macro, with definition 1.

-D name=definition
The contents of definition are tokenized and processed as if they
appeared during translation phase three in a #define directive. In
particular, the definition will be truncated by embedded newline
characters.
I've never used it, so you must figure it out yourself or wait till someone else comes along. And as far as I know it's called a preprocessor directive.

PS There is a dedicated programming section. Usefull for future programming related questions.

Last edited by Wim Sturkenboom; 08-31-2007 at 09:07 AM. Reason: Added PS
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
The C Preprocessor slzckboy Programming 9 04-15-2007 01:46 PM
C pre-preprocessor or preprocessor replacement Tischbein Programming 3 02-11-2007 11:38 AM
How do you add new printer from the text console? (Minimal installation) Akhran Debian 3 06-28-2006 08:20 AM
add a program to run in vty/console at boot? carl0ski Mandriva 3 11-23-2004 06:07 AM
how to add a directory from the console FuGeE Linux - General 1 08-06-2003 12:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration