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

  • Home
  • SEARCH
  • 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 7996205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:39:02+00:00 2026-06-04T14:39:02+00:00

I came across something the other day for setting the value of C Structs

  • 0

I came across something the other day for setting the value of C Structs by using curly braces and it works great but I’m wondering why exactly can I not use it for setting the value of properties?

//This works:
CGPoint pt = {10, 20};
CGRect rct = {0, 5, 50, 50};

//But this doesn't:
self.frame = {0, 5, 50, 50};
imageview.center = {100, 120};

The compiler error is “expected expression”

I think I know why this doesn’t work, but I would like a more thorough explanation.

  • 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-06-04T14:39:04+00:00Added an answer on June 4, 2026 at 2:39 pm

    The first lines combine declaration and initialisation of variables. The compiler infers the type of the right expression from the type of the left expression, and distributes the numbers in the struct slots as expected.

    The last lines, however, are not initialisations. Now the compiler won’t infer anything. As a consequence, the compiler doesn’t know how it should interpret the stuff on the right. What is its type, how to layout those numbers in memory ? The compiler won’t assume its CGrect or CGPoint, and you must help him with an explicit cast (CGRect){0,5,50,50} which gives him the missing information.

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

Sidebar

Related Questions

Some background: I came across something the other day that got me thinking about
The other day I was doing some Python benchmarking and I came across something
Came across something like this today, and was wondering if there was an equivalent
I came across something very basic but extremely bewildering today. I needed to convert
The other day I came across an alternative way of accessing web.config configuration in
I came across some code the other day and I wondered if that was
I'm encountering something a bit bizarre, but maybe someone else came across this before.
I've came across something that drives me crazy. please help me :( I'm try
So while rewriting some code, I came across something along the lines of: Method
I have a question regarding Twitter API. I came across something called Parameters and

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.