Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ccall in a macro creates a local scope #4893

Closed
aviks opened this issue Nov 22, 2013 · 2 comments
Closed

ccall in a macro creates a local scope #4893

aviks opened this issue Nov 22, 2013 · 2 comments

Comments

@aviks
Copy link
Member

aviks commented Nov 22, 2013

julia> macro test(a)
          quote
              immutable $(esc((symbol(a))))
                  x::Int
              end
          end
       end
julia> 

julia> @test "a1"

julia> a1
a1 (constructor with 1 method)

julia> macro test(a)
          quote
              immutable $(esc((symbol(a))))
                  x::Int
              end
              ccall( (:clock, "libc"), Int32, ()) 
           end 
       end 

julia> @test "a2"
ERROR: error compiling anonymous: type definition not allowed inside a local scope

julia> 

Is this expected behaviour? Workaround is to wrap the ccall in an eval.

@JeffBezanson
Copy link
Sponsor Member

This is pretty much the same issue as #2586.

@aviks
Copy link
Member Author

aviks commented Nov 22, 2013

Ah, OK, thanks. Closing as a duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants