473,387 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Question about definitions

Hi,
I don't understand the following definitions in a
header-file for sample codes, that have been written in msvs.
I try to get the sample codes "clean" to compiling them
with the GNU-Compiler.

#ifdef _X86_
#define DebugBreak() _asm { int 3 }
#endif
When using DebugBreak, the GNU-Compiler prints the error:

inline void chFAIL(PSTR szMsg) {
chMB(szMsg);
DebugBreak(); //error*

}

*error: multiple markers at this line
- _asm undeclared (first use this function)
- parse error before '{' token
I am also confused of "_asm { int 3 } " I can't find an
explanation for that in my C++ books.
#define chBEGINTHREADEX(psa, cbStack, pfnStartAddr, \
pvParam, fdwCreate, pdwThreadId) \
((HANDLE)_beginthreadex( \
(void *) (psa), \
(unsigned) (cbStack), \
(PTHREAD_START) (pfnStartAddr), \
(void *) (pvParam), \
(unsigned) (fdwCreate), \
(unsigned *) (pdwThreadId)))
An inline function is the better choice, isn't it?

Thanks in advance,
Thomas B.
Jul 22 '05 #1
3 2853
Thomas Barth wrote:
Hi,
I don't understand the following definitions in a
header-file for sample codes, that have been written in msvs.
I try to get the sample codes "clean" to compiling them
with the GNU-Compiler.

#ifdef _X86_
#define DebugBreak() _asm { int 3 }
#endif
When using DebugBreak, the GNU-Compiler prints the error:

inline void chFAIL(PSTR szMsg) {
chMB(szMsg);
DebugBreak(); //error*

}

*error: multiple markers at this line
- _asm undeclared (first use this function)
- parse error before '{' token


inline assembly is non standard and usually highly compiler
dependant.
Read up on inline asm in the gcc docs, the above seems to be written
for another compiler.

--
Nils O. Selåsdal
www.utelsystems.com
Jul 22 '05 #2

"Thomas Barth" <th******@mail.isis.de> wrote in message
news:2v*************@uni-berlin.de...
Hi,
I don't understand the following definitions in a
header-file for sample codes, that have been written in msvs.
I try to get the sample codes "clean" to compiling them
with the GNU-Compiler.

#ifdef _X86_
#define DebugBreak() _asm { int 3 }
#endif
When using DebugBreak, the GNU-Compiler prints the error:

inline void chFAIL(PSTR szMsg) {
chMB(szMsg);
DebugBreak(); //error*

}

*error: multiple markers at this line
- _asm undeclared (first use this function)
- parse error before '{' token
I am also confused of "_asm { int 3 } " I can't find an
explanation for that in my C++ books.
_asm is non-standard, that is why you can't find it in your C++ books and
why the g++ compiler won't compile it. You will have to check with an MS
group but I think that DebugBreak is a way of activating the debugger for
your system. I have no idea what the equivalent for g++ would be.


#define chBEGINTHREADEX(psa, cbStack, pfnStartAddr, \
pvParam, fdwCreate, pdwThreadId) \
((HANDLE)_beginthreadex( \
(void *) (psa), \
(unsigned) (cbStack), \
(PTHREAD_START) (pfnStartAddr), \
(void *) (pvParam), \
(unsigned) (fdwCreate), \
(unsigned *) (pdwThreadId)))
An inline function is the better choice, isn't it?


Yes.

John

Jul 22 '05 #3
Thomas Barth wrote:
I don't understand the following definitions in a
header-file for sample codes, that have been written in msvs.
I try to get the sample codes "clean" to compiling them
with the GNU-Compiler.

#ifdef _X86_
#define DebugBreak() _asm { int 3 }
#endif
When using DebugBreak, the GNU-Compiler prints the error:

inline void chFAIL(PSTR szMsg) {
chMB(szMsg);
DebugBreak(); //error*

}

*error: multiple markers at this line
- _asm undeclared (first use this function)
- parse error before '{' token
Well, you could try replacing '_asm' with 'asm' to get it to work,
but beware that interrupt 3 is not necessarily supported in your GNU
debugger as a 'software breakpoint'.

_asm is Microsoft-specific. Using 'int 3' as a "software breakpoint"
is also Microsoft-specific. I recommend you change the macro to be

#ifdef _X86_
# ifdef _MSC_VER
# define DebugBreak() _asm { int 3 }
# else
# define DebugBreak() 0
# endif
#endif


I am also confused of "_asm { int 3 } " I can't find an
explanation for that in my C++ books.
You're reading wrong books :-). You need Microsoft-specific ones.
#define chBEGINTHREADEX(psa, cbStack, pfnStartAddr, \
pvParam, fdwCreate, pdwThreadId) \
((HANDLE)_beginthreadex( \
(void *) (psa), \
(unsigned) (cbStack), \
(PTHREAD_START) (pfnStartAddr), \
(void *) (pvParam), \
(unsigned) (fdwCreate), \
(unsigned *) (pdwThreadId)))
An inline function is the better choice, isn't it?


Better choice for what?

V
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Skulled2003 | last post by:
Hello, I have a question on import. I have a file which contains some assorted lists, and some other definitions. But all of the list names have a common part to it and a specific part in the...
9
by: Dave H | last post by:
Hello, I have a query regarding definition lists. Is it good practice semantically to use the dt and dd elements to mark up questions and answers in a frequently asked questions list, or FAQ? ...
4
by: Tony Johansson | last post by:
Hello experts! I'm reading a book about C++ and there is something about inline that the book says that is unclear for me. The book says the following "Because inline functions are expanded at...
55
by: ben | last post by:
is it true that a function without an inline keyword never get inlined? If not true when is it inlined or not? ben
7
by: David Hayes | last post by:
I tried finding an answer on http://www.quirksmode.org/ without success. I am attempting a complicated Frames structure. I have made it work in IE, but not Netscape. I begin with three...
2
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data...
24
by: ark | last post by:
Hello group, Could you help me with this: static const int x; ............ something ............. static const int x = 17; It looks perfectly legal to me but MSVC/C++ 6.0 gives, on the...
19
by: Randy Yates | last post by:
Consider the following code: #include "dsptypes.h" /* definitions */ #define VECTOR_LENGTH 64 /* local variables */
12
by: Bit byte | last post by:
I have an application written in C (actually PostgreSQL). The application appears to have been built using the Mingw set of tools (mingw compiler tools). I want to write an extension library...
14
by: Paulo Jorge de O. C. de Matos | last post by:
Hello all, I am trying to understand in detail the correct wording to use in C for teaching purposes. For the example: int foo(int x, int y) { int k; ... return k; }
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.