LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 06-27-2009, 09:32 AM   #1
Kunsheng
Member
 
Registered: Mar 2009
Posts: 82

Rep: Reputation: 16
Operator 'typeof' is not identified in Visual Studio C++ 8.0 ?


Hello everyone,

I am using some Linux Kernel code (list implementation) in my Visual Studio 2005 (C++),

It reminds me

'typeof': identifier not found'.

I tried __typeof__ but still not working.

Any idea ?


Thx,

-Kun
 
Old 06-27-2009, 11:58 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Code snippet and/or source filename please?
 
Old 06-27-2009, 12:58 PM   #3
Kunsheng
Member
 
Registered: Mar 2009
Posts: 82

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by paulsm4 View Post
Code snippet and/or source filename please?
It is the list implementation in Linux. (include/linux/list.h), It is already used by my code in Linux version and I prefer to change a little bit to adapted to Windows

The function has typeof type as one of its parameters:

------------------------------------------------------------------

#define list_for_each_entry_safe(pos, n, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))



-------------------------------------------------------------------


Thx,

-Kun
 
Old 06-27-2009, 01:37 PM   #4
Kunsheng
Member
 
Registered: Mar 2009
Posts: 82

Original Poster
Rep: Reputation: 16
HI, Paul, I use typeid() instead of typeof and it works.



Quote:
Originally Posted by paulsm4 View Post
Code snippet and/or source filename please?
 
Old 06-27-2009, 09:10 PM   #5
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Cool - glad you found a solution.

For whatever it's worth, I'm familiar with both GCC and Visual Studio ... and I wasn't aware of the "typeof" <=> "typeid" solution> Thank you for the tip!

Also for whatever it's worth, the kernel authors make no bones about the fact that Linux really isn't meant to be built with any compiler besides gcc. *Platform* portability is an important consideration (Linux runs on lots of different kinds of hardware). *Compiler* portability isn't: gcc is available (or can be readily bootstrapped) wherever it's needed; ANSI C doesn't provide all the needed features (I guess "typeof" is one good example!). So GCC is pretty much the "annointed compiler" for Linux kernel code.

IMHO .. PSM

PS:
I would argue, however, that all good *application* code (vs. "kernel code") should be written in portable ANSI C or ANSI C++ whenever practical.

Last edited by paulsm4; 06-27-2009 at 09:12 PM.
 
  


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
Stupid Question: Microsoft Visual Studio 6.0 (A.K.A. Visual Basic 6) Will it run? S0RD3N Linux - Software 8 05-07-2008 08:42 PM
GCC vs VISUAL STUDIO paragkalra Linux - Software 1 01-05-2007 01:21 AM
IDE like visual studio zakkeyboorock Programming 5 03-22-2006 01:12 PM
visual studio on wine supermatt Linux - Software 5 03-03-2004 04:16 PM
Is Visual Studio in Linux??? rob99 Linux - Software 6 01-22-2003 04:33 PM

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

All times are GMT -5. The time now is 04:59 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
Open Source Consulting | Domain Registration