Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6608059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:34:10+00:00 2026-05-25T19:34:10+00:00

#define PORTC *(unsigned char volatile *)(0x1003) #define DDRC *(unsigned char volatile *)(0x1007) So I’ve

  • 0

#define PORTC *(unsigned char volatile *)(0x1003)

#define DDRC *(unsigned char volatile *)(0x1007)

So I’ve been trying to read some stuff about embedded C. Initially I thought this macro was a pointer-to-pointer type but then I soon assumed the last star is actually a dereference rather than a type-cast, am I correct? Dereferencing to the location 0x1003/0x1007.

It is used like: PORTC = <some hex value>

Question is what makes this different from a pointer type-cast? Is there some sort of ‘provision’ in the C specifications? Or am I just an idiot…

Also I don’t quite know how to phrase this and so I couldn’t do a quick search first…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:34:11+00:00Added an answer on May 25, 2026 at 7:34 pm

    It’s just the way the C grammar is defined.

    To be a cast, the expression needs parenthesis: (type)sub-expression casts sub-expression to type type.

    Your example, *(unsigned char volatile *)(0x1003) is composed of 2 sub-expressions:

    • a “lonely” star: *
    • a cast: (unsigned char volatile *)(0x1003)

    The cast is composed of the type inside () and a value.

    So, the whole expression is interpreted as a pointer, then de-referenced to set the memory area pointed to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The function: #define ASSOC(port) (*(volatile bit_field *) (&port)) The function call: #define SCLK ASSOC(PORTC).bit0
I define some Entities which works fine; for meta programming issues. I now need
I'm trying to figure out some C code so that I can port it
I'm trying to port some assembly code written in Visual Studio into GNU inline
I am trying to write and read data from EEPROM (microcontroller ATmega2560 ), which
I am trying to write and read data from EEPROM (microcontroller ATmega2560 ), which
(define bootstrap-c-code (define (from-file file-name) (let* ((ip (open-input-file file-name)) (res (read-text-file-from-input-port ip))) (close-input-port ip)
I am trying to port some relatively modern C code to an older compiler.
I've got a bare-minimum Erlang port driver: erl_driver_bridge.c -> erl_driver_bridge.dll #define __WIN32__ #include erl_driver.h
(define a 42) (set! 'a 10) (define a 42) (define (symbol) 'a) (set! (symbol)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.