IOKit header assert.h gone?

I want to get the hardware address of my mac's ethernet card. In all samples I saw in include on IOKit/assert.h . Which doesn't seem to exist on my system. GCC throws an error saying he doesn't know the type IOEthernetAddress. Is assert.h necessary for my task? It would be great if someone coud give me a working sample. [edit] here's my code, think this will help understanding the problem:

#include <IOKit/assert.h> #include <IOKit/network/IOEthernetController.h> #include <IOKit/network/IOEthernetInterface.h> int main(){ IOEthernetAddress addr; getHardwareAddress(&addr); printf("%x", addr); return 0; }

-------------Problems Reply------------

You must be trying to do this from userspace; you wouldn't be using main() if you were writing for the kernel. however, these are kernel include files. One way to do this from userspace is to look at the I/O registry, and find the IOMACAddress for the piece of hardware that interests you. To get started with this, take a look at I/O Registry Explorer.

Another way is to use ioctl with SIOCSIFLLADDR, to get the link level address.

Category:c# Views:1 Time:2010-03-22
Tags: c# osx assert iokit

Related post

  • iPhone app "has active assertions beyond permitted time" 2010-09-06

    I'm trying to make sense of some crash logs I received for my iPhone app. The main thing that I can see that's useful is: Application Specific Information: MyMoodTrack[144] has active assertions beyond permitted time: {( <SBProcessAssertion: 0x73c

  • When should assertions stay in production code? 2008-08-20

    There's a discussion going on over at comp.lang.c++.moderated about whether or not assertions, which in C++ only exist in debug builds by default, should be kept in production code or not. Obviously, each project is unique, so my question here is not

  • How can I assert() without using abort()? 2008-09-01

    If I use assert() and the assertion fails then assert() will call abort(), ending the running program abruptly. I can't afford that in my production code. Is there a way to assert in runtime yet be able to catch failed assertions so I have the chance

  • Test Cases AND assertion statements 2008-09-11

    The code in this question made me think assert(value>0); //Precondition if (value>0) { //Doit } I never write the if-statement. Asserting is enough/all you can do. "Crash early, crash often" CodeComplete states: The assert-statement makes the a

  • Debug.Assert vs. Specific Thrown Exceptions 2008-09-14

    I've just started skimming 'Debugging MS .Net 2.0 Applications' by John Robbins, and have become confused by his evangelism for Debug.Assert(...). He points out that well-implemented Asserts store the state, somewhat, of an error condition, e.g.: Deb

  • How to disable a programmatical breakpoint / assert? 2008-09-22

    I am using Visual Studio, developing a native application, I have a programmatical breakpoint (assert) in my code placed using __asm int 3 or __debugbreak. Sometimes when I hit it, I would like to disable it so that successive hits in the same debugg

  • Is Assert.Fail() considered bad practice? 2008-09-23

    I use Assert.Fail a lot when doing TDD. I'm usually working on one test at a time but when I get ideas for things I want to implement later I quickly write an empty test where the name of the test method indicates what I want to implement as sort of

  • When should I use Debug.Assert()? 2008-09-24

    I've been a professional software engineer for about a year now, having graduated with a CS degree. I've known about assertions for a while in C++ and C, but had no idea they existed in C# and .NET at all until recently. Our production code contains

  • Unit Testing without Assertions 2008-09-26

    Occasionally I come accross a unit test that doesn't Assert anything. The particular example I came across this morning was testing that a log file got written to when a condition was met. The assumption was that if no error was thrown the test passe

  • Is it idiomatic Ruby to add an assert( ) method to Ruby's Kernel class? 2008-09-29

    I'm expanding my Ruby understanding by coding an equivalent of Kent Beck's xUnit in Ruby. Python (which Kent writes in) has an assert() method in the language which is used extensively. Ruby does not. I think it should be easy to add this but is Kern

  • The best way to assert pre-condition and post-condition of arguments and values in .NET? 2008-09-30

    I have been thinking about design by contract lately and I was wondering what people think is the best way to assert pre-condition and post-condition of values in .NET? i.e. validating argument values to a method. Some people recommend Debug.Assert w

  • How do you assert that a certain exception is thrown in JUnit 4 tests? 2008-10-01

    How can I use JUnit4 idiomatically to test that some code throws an exception? While I can certainly do something like this: @Test public void testFooThrowsIndexOutOfBoundsException() { boolean thrown = false; try { foo.doStuff(); } catch (IndexOutOf

  • C# - What does the assert() method do? Is it still useful? 2008-10-02

    I am debugging with breakpoints and I realize the assert call? I thought it was only for unit tests. What does it do more than breakpoint? Since I can breakpoint, why should I use Assert? --------------Solutions------------- In a debug compilation, A

  • Design of an performance assertion checking system 2008-10-03

    What are opinions on the design of a "performance assertion checking" system? The idea is that a developer makes some assertions about his/her code and use these to test the evolution of the performance of the code. What is the experience with such a

  • NUnit: Running multiple assertions in a single test 2008-10-03

    I have been asked to write a testing application that needs to test a new stored procedure on multiple rows in a database, in essence I want to do something like this: [Test] public void TestSelect() { foreach(id in ids) { DataTable old =

  • Ways to ASSERT expressions at build time in C 2008-10-06

    I'm tidying up some older code that uses 'magic numbers' all over the place to set hardware registers, and I would like to use constants instead of these numbers to make the code somewhat more expressive (in fact they will map to the names/values use

  • What is the best way of implementing assertion checking in C++? 2008-10-07

    By that I mean, what do I need to do to have useful assertions in my code? MFC is quite easy, i just use ASSERT(something). What's the non-MFC way? Edit: Is it possible to stop assert breaking in assert.c rather than than my file which called assert(

  • iPhone SDK: Assertion failure in -[UILabel setFont:] 2008-10-15

    I have an iPhone app that compiles and runs fine in the Simulator on my laptop. Now, I try to build and run the same code in the Simulator on an iMac, and it starts up and lets me click a button, but then I get an assertion failure. Here is what is i

  • ActiveX plugin causes ASSERT to fail on application exit in VS2008 2008-10-15

    My MFC application using the "ESRI MapObjects LT2" ActiveX plugin throws an ASSERT at me when closing it. The error occurs in cmdtarg.cpp: CCmdTarget::~CCmdTarget() { #ifndef _AFX_NO_OLE_SUPPORT if (m_xDispatch.m_vtbl != 0) ((COleDispatchImpl*)&m

Copyright (C), All Rights Reserved.

processed in 0.122 (s). 11 q(s)