* MIsc C programming questions
@ 2005-10-24 9:02 fabio
2005-10-24 10:02 ` Steve Graegert
0 siblings, 1 reply; 2+ messages in thread
From: fabio @ 2005-10-24 9:02 UTC (permalink / raw)
To: linux-c-programming
Hello,
I have some questions about C programming not exactly on Linux but
Solaris, I hope you can help me:
- Why I cant include this __asm___ lines on a C program and compile it
on Sun cc on Solaris 10?
-bash-3.00$ cat ret.c; cc ret.c
/*
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/systeminfo.h>
/*
*
*/
int
main() {
int ret;
ret = get_sp();
printf("Stack Pointer is: 0x%x\n",ret);
char platform[257],release[257];
sysinfo(SI_PLATFORM, platform, sizeof(platform) - 1);
sysinfo(SI_RELEASE, release, sizeof(release) - 1);
printf("Platform: %s (%s)\n", platform, release);
return (EXIT_SUCCESS);
}
int
get_sp(){
__asm__("mov %sp,%g1");
__asm__("mov %g1,%o1");
}
"ret.c", line 16: warning: implicit function declaration: get_sp
"ret.c", line 27: warning: implicit function declaration: __asm__
Undefined first referenced
symbol in file
__asm__ ret.o
ld: fatal: Symbol referencing errors. No output written to a.out
-bash-3.00$
Any workaround?
Thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: MIsc C programming questions
2005-10-24 9:02 MIsc C programming questions fabio
@ 2005-10-24 10:02 ` Steve Graegert
0 siblings, 0 replies; 2+ messages in thread
From: Steve Graegert @ 2005-10-24 10:02 UTC (permalink / raw)
To: linux-c-programming
On 10/24/05, fabio <fabio@crearium.com> wrote:
> Hello,
>
> I have some questions about C programming not exactly on Linux but
> Solaris, I hope you can help me:
>
> - Why I cant include this __asm___ lines on a C program and compile it
> on Sun cc on Solaris 10?
Because Sun's C compiler doesn't support __asm__ which is a GNU extension.
> Any workaround?
Use the asm keyword instead:
asm("mov %sp,%g1");
asm("mov %g1,%o1");
Does it help?
\Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-10-24 10:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-24 9:02 MIsc C programming questions fabio
2005-10-24 10:02 ` Steve Graegert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).