LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-12-2017, 03:23 PM   #1
Fractal Cat
LQ Newbie
 
Registered: Jul 2017
Posts: 8

Rep: Reputation: Disabled
Question c header file to assembler header file


Hi,

Is there a tool that will take a C/C++ header file and convert it into an assembler header file ?

FC.
 
Old 08-12-2017, 05:26 PM   #2
rigor
Member
 
Registered: Sep 2011
Posts: 253

Rep: Reputation: Disabled
Hi Fractal Cat,


AFAIK, in principle, this a general purpose Programming forum, not specific to any Operating System, or compiling environment. So you might want to consider providing some details about what OS, what compiler, possibly even what CPU you would be using, and in what form you wish a C header converted to an Assembly language header.

For example, on Linux for x86_64 "architecture",

header.h:
Code:
# include <stdio.h>

int two_plus_two()
{
    return  2  +  2 ;  
}
header_to_asm.c:
Code:
# include "header.h"


void main(  int  argc ,  char *arv[]  )
{
    printf(  "2 + 2 = %d\n" ,  two_plus_two() ) ;
}
Output from running header_to_asm executable after building with gcc:
Code:
2 + 2 = 4
I believe using the gcc compiler driver, Assembly language code is generated from C code, then run through the Assembler and the resulting Object files, through the linker. If it's desired, the compiler driver option "-S" can be used to get the intermediate assembly language output, and stop the build at that point in the build prodecure. Since in C, a header might contain just about anything that a non-header could contain, and the intermediate Assembly language output is available, you could potentially turn the intermediate Assembly language output into a header fairly easily.

On the other hand, there are various ARM environments in which I believe that Assembly language output can be generated and kept for later use as a part of the normal executable build procedure without stopping the build at that point, and there are even ARM environments that allow the use of C language includes directly in Assembly language; there isn't necessarily a need to convert headers from C to Assembly language.

Overall, it might be fair to say that the answer to your question might be different depending on the environment in which, and to consider possible cross-compiling, for which, you wish to compile.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Header file for C shailesh012 Linux - Newbie 2 03-02-2015 05:00 AM
Header file in C tushar_pandey Programming 8 07-31-2012 11:47 PM
How to check missing header files included from another header file adisan82 Linux - Software 1 01-28-2011 03:57 AM
header file saadiaomar Programming 4 03-23-2006 04:18 PM
Create header file for existing .c file hk_michael Programming 5 02-25-2005 05:26 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:10 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration